main.py
-
FastAPI - main.py 구성하기Backend/FastAPI 2023. 6. 26. 21:13
필자도 Fastapi를 처음 접했을 때, main.py에 test용 api를 만들고 풀 명령어를 이용하여 test를 했었다. (아래와 같이) from fastapi import FastAPI from typing import Union app = FastAPI() @app.get("/") def root(): return {"hello root"} @app.get("/world") def world(): return {"hello world"} @app.get("/table/{item_id}") def read_item(item_id: int, q: Union[str, None] = None): return {"item_id": item_id, "q": q} 명령어 : uvicorn main:app --..