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

 

相关文章:

  • 2021-12-23
  • 2021-11-19
  • 2021-11-07
  • 2021-07-15
  • 2021-06-26
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2018-07-05
  • 2022-12-23
  • 2021-11-04
  • 2021-09-09
  • 2022-12-23
相关资源
相似解决方案