Class-based views for the FastAPI
Project description
cbfa
Немного манки-патчинга для FastAPI, хендлеры на основе классов. Пока без поддержки self
.
Устанавливаем:
$ pip install cbfa
И используем:
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel
from cbfa import ClassBased
app = FastAPI()
wrapper = ClassBased(app)
class Item(BaseModel):
name: str
price: float
is_offer: Optional[bool] = None
@wrapper('/item')
class Item:
def get(item_id: int, q: Optional[str] = None):
return {"item_id": item_id, "q": q}
def post(item_id: int, item: Item):
return {"item_name": item.name, "item_id": item_id}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cbfa-0.0.1.tar.gz
(2.0 kB
view hashes)
Built Distribution
cbfa-0.0.1-py3-none-any.whl
(3.0 kB
view hashes)