-
FastApi FastApi คืออะไร?
- FastApi ทำงานอย่างไร
- ใครเป็นคนสร้าง
- FastApi In production
-
RESTFul
- What's RESTFul
- มีประโยชน์อย่างไร
- Concept of restful
-
CRUD
- คืออะไร
-
Tools
-
VSCode Extension
- python
- pylance
-
pip
-
-
Install Fast Api with pip
python3 -m venv env
pip install fastapi
pip install uvicorn[standard]
-
Install Fast Api with pip (Windows)
python -m venv env
env/Scripts/activate
pip install fastapi
pip install uvicorn[standard]
-
Hello world
- Ref
- Create simple fast-api
from fastapi import FastAPI app = FastAPI() @app.get("/") async def root(): return {"message": "Hello World"}
- run api
uvicorn main:app --reload
-
Swagger UI
-
Path Parameters
- get book by name
from fastapi import FastAPI app = FastAPI() @app.get("/books/{book_name}") async def read_item(book_name: str): return {"book_name": book_name}
-
Pydantic
- Ref
- What's pydantic
- it's data validation