安装,参考 https://fastapi.tiangolo.com/zh/tutorial/
pip install fastapi
pip install uvicorn
faTest.py 文件:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
命令行运行一下:
uvicorn faTest:app --reload
浏览器访问 http://127.0.0.1:8000/
得到 json数据: {"message":"Hello World"}
正文完