FastAPI hello-word

时间:2021-07-21 09:39:52   收藏:0   阅读:29
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)

技术分享图片

 

原文:https://www.cnblogs.com/luckygxf/p/15037762.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!