开发者社区 > 云原生 > Serverless > 正文

Python FASTAPI 的 serverless_config 如何设置?

已有的项目是基于FASTAPI框架 开发的https://github.com/tiangolo/fastapi

如何迁移到云开发

展开
收起
1302886654860739 2020-11-17 17:57:21 1470 0
2 条回答
写回答
取消 提交回答
  • Talk is cheap, show me the code.

    查看文档 https://help.aliyun.com/document_detail/183365.html?spm=a2c4g.11186623.6.578.49e6388chHya1p

    2020-11-20 11:00:39
    赞同 展开评论 打赏
  • main.py

    from typing import Optional import uvicorn from fastapi import FastAPI

    app = FastAPI()

    @app.get("/") def read_root(): return {"Hello": "World"}

    @app.get("/items/{item_id}") def read_item(item_id: int, q: Optional[str] = None): return {"item_id": item_id, "q": q}

    if name == 'main':

    uvicorn.run(app='main:app', host='0.0.0.0',port=8020, debug=False, reload=True)
    

    测试报错 erver Error: [2020-11-17 11:19:21 +0000] [1383] [ERROR] Error handling request / Traceback (most recent call last): File "/home/admin/.local/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 134, in handle self.handle_request(listener, req, client, addr) File "/home/admin/.local/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 175, in handle_request respiter = self.wsgi(environ, resp.start_response) TypeError: call() missing 1 required positional argument: 'send'

    2020-11-25 17:20:47
    赞同 展开评论 打赏

快速交付实现商业价值。

相关产品

  • 函数计算
  • 热门讨论

    热门文章

    相关电子书

    更多
    Serverless 引领云上研发新范式 立即下载
    All in Serverless 阿里云核心产品全面升级 立即下载
    AIGC 浪潮之上,森马的 Serverless 实践之旅 立即下载