no.2_helloworld
1 新建main.py
# https://fastapi.tiangolo.com/tutorial/
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
if __name__=='__main__':
import uvicorn
uvicorn.run(app,host='127.0.0.1',port=8000)
# uvicorn main:app --reload
2 测试
http://127.0.0.1:8000