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

Python FASTAPI 的 serverless_config 如何设置?

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

如何迁移到云开发

展开
收起
1302886654860739 2020-11-17 17:57:21 1506 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
    赞同 展开评论 打赏

快速交付实现商业价值。

相关产品

  • 函数计算
  • 热门讨论

    热门文章

    相关电子书

    更多
    From Python Scikit-Learn to Sc 立即下载
    Data Pre-Processing in Python: 立即下载
    双剑合璧-Python和大数据计算平台的结合 立即下载