[FastAPI] 설치 및 기본설정

설치

$ pip install fastapi[all] # zsh면 pip install fastapi\[all\]로 $ pip install uvicorn
Python
복사
기본
from fastapi import FastAPI app = FastAPI() @app.get("/") async def root(): return {"message": "Hello World"}
Python
복사
main.py
구조
├── app │ ├── __init__.py │ ├── main.py │ ├── dependencies.py │ └── routers │ │ ├── __init__.py │ │ ├── items.py │ │ └── users.py │ └── internal │ ├── __init__.py │ └── admin.py
Python
복사