카테고리 없음
FastAPI
jmani
2022. 7. 6. 11:27
doc: https://fastapi.tiangolo.com/
pip install fastapi
pip install uvicorn
ASGI: Asynchronous Server Gateway Interface
uvicorn: 비동기 방식의 http server > ASGI
# main.py
from fastapi import FastAPI
app = FastAPI() # 인스턴스 생성
@app.get("/") # get method로 '/'에 해당하는 생성
def root():
return {'Hello':'World!'}
uvicorn main:app --reload
- main: module name, main.py
- app: app = FastAPI()
- --reload: make the server restart after code changes. Only usse for development.
Swagger UI
link: localhost:8000/docs
- Try it out
- 실행가능
Redoc UI
link: localhost:8000/redoc
- openapi.json 다운 가능
- 실행은 안됨