pip3 install fastapi # ASGI 服务:uvicorn: pip3 install uvicorn
from fastapi import FastAPI
import uvicorn
app = FastAPI()
@app.get("/{name}")
def read_root(name):
return {"Hello": "World, " + name}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
return {"item_id": item_id, "q": q}
if __name__ == '__main__':
uvicorn.run(app='img:app', host="127.0.0.1", port=8000, reload=True, debug=True)
ERROR: Error loading ASGI app. Could not import module "img".
源码文件名称不对原因