官方文档:Server Workers - Gunicorn with Uvicorn - FastAPI
使用 fastapi 运行命令
¶
可以直接使用fastapi run命令来启动FastAPI应用:
fastapi run main.py
如创建openapi.py文件:
from fastapi import FastAPI
app = FastAPI(openapi_url="/api/v1/openapi.json")
@app.get("/items/")
async def read_items():
return [{"name": "Foo"}]
然后执行:
fastapi run openapi.py
启动后显示:
INFO Using path openapi.py
INFO Resolved absolute path
/Users/skywalk/work/fastapi/openapi.py
INFO Searching for package file structure from directories with
__init__.py files
INFO Importing from /Users/skywalk/work/fastapi
╭─ Python module file ─╮
│ │
│
标签:INFO,11,Gunicorn,FastAPI,worker,Uvicorn,0.0
From: https://blog.csdn.net/skywalk8163/article/details/143484976