当前位置:首页 > IT技术 > Windows编程 > 正文

FastAPI hello-word
2021-08-07 11:02:04

from typing import Optional

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
    return {"item_id": item_id, "q": q}


if __name__ == '__main__':
    import uvicorn

    uvicorn.run(app, host="localhost", port=8080)

FastAPI hello-word_ico

 

本文摘自 :https://blog.51cto.com/u

开通会员,享受整站包年服务立即开通 >