xuehuiping
# -*- encoding: utf-8 -*-
"""
@date: 2021/4/23 3:42 下午
@author: xuehuiping
"""
from fastapi import FastAPI
import uvicorn

app = FastAPI()


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


@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, host="127.0.0.1", port=8000)

也可以这么运行
uvicorn main:app --reload

交互文档
http://127.0.0.1:8000/docs 可以查看路径及参数

API文档
http://127.0.0.1:8000/redoc

分类:

技术点:

相关文章:

  • 2021-06-17
  • 2021-11-02
  • 2022-12-23
  • 2021-11-06
  • 2021-12-14
  • 2022-12-23
  • 2018-01-30
猜你喜欢
  • 2020-04-18
  • 2022-12-23
  • 2021-06-08
  • 2021-10-07
  • 2021-11-02
  • 2022-12-23
相关资源
相似解决方案