【问题标题】:trying to setup connexion.AioHttpApp() with aiohttp-cors for async routes fails尝试使用 aiohttp-cors 为异步路由设置 connexion.AioHttpApp() 失败
【发布时间】:2022-01-21 09:18:51
【问题描述】:

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

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

connexion配置如下:

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' 对象没有属性'router'

【问题讨论】:

    标签: python asynchronous cors event-loop connexion


    【解决方案1】:

    你必须使用app.app

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-21
      • 1970-01-01
      相关资源
      最近更新 更多