gpt4 book ai didi

python - 尝试使用 aiohttp-cors 设置 connexion.AioHttpApp() 来实现异步路由失败

转载 作者:行者123 更新时间:2023-12-01 07:26:27 29 4
gpt4 key购买 nike

我正在尝试转换使用 connexionCORS 的现有 Web 应用程序能够处理异步路由。

(直接从事件循环内调用异步函数可以正常工作)

连接配置如下:

connexion = {extras = ["aiohttp_swagger"],version = "*"}.
app = connexion.AioHttpApp(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml')
cors = aiohttp_cors.setup(app)

我只是希望 connexion 以异步模式运行并能够处理异步路由。

返回当前的 cors 设置

'AioHttpApp' object has no attribute 'router'

最佳答案

您必须使用app.app

app = connexion.AioHttpApp(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml')
cors = aiohttp_cors.setup(app.app)

关于python - 尝试使用 aiohttp-cors 设置 connexion.AioHttpApp() 来实现异步路由失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57425403/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com