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)

python  发布api框架  fastapi   flask restful   Api构建框架_文件名

python  发布api框架  fastapi   flask restful   Api构建框架_文件名_02




python  发布api框架  fastapi   flask restful   Api构建框架_ico_03


 ERROR:    Error loading ASGI app. Could not import module "img".

源码文件名称不对原因