# FastAPI ASGI interface (gunicorn is WSGI like Flask) ## Contains - OpenAPI / SwaggerUI - Pydantic - SQLAlchemy (ORM) ## Document of OpenAPI ### /docs - SwaggerUI interface ### /openapi.json - OpenAPI standard json format ## Path parameter #### path part of reauest URI - /book/book_1 ## variable in path will become "Path parameter" ```python @app.get("/{book_name}") async def read_book(book_name: str): return BOOKS[book_name] ``` ### path order is important 1. /book/mybook 2. /book/{book_name} ``` order must be 1 -> 2 or if the order is 2 -> 1 , it will go in to 2 and never go in to 1 ``` ## Query parameter query part of reauest URI - /book?book_id=2 ## variable not in path will become "Query parameter" ```python @app.get("/") async def read_book(book_name: str): return BOOKS[book_name] ``` ## Enum use Enum as param type can show as input box in swaggerUI # Pydantic ## action items - Async test - IT 所有api文件整合