Fast restful API based on FastAPI and TortoiseORM
Project description
fastapi-rest
Introduction
Fast restful API based on FastAPI and TortoiseORM.
Install
pip install fastapi-rest
Quick Start
First, define your ListView
resource.
from fastapi_rest.resource import ListView
class UserList(ListView):
model = User
fields = ("name", "age")
Second, include router to your app.
app.include_router(UserList.as_router())
Now, you can visit the endpoint /user
to get user list.
ListView
Export the endpoint GET /{resource}
.
class ListView(Resource):
paginator: Paginator = Paginator()
fields: Optional[Tuple[str, ...]] = None
exclude: Optional[Tuple[str, ...]] = None
queryset: Optional[QuerySet] = None
DetailView
Export the endpoint GET /{resource}/{pk}
.
class DetailView(Resource):
fields: Optional[Tuple[str, ...]] = None
exclude: Optional[Tuple[str, ...]] = None
CreateView
Export the endpoint POST /{resource}
.
class CreateView(Resource):
schema: Optional[Type[BaseModel]] = None
UpdateView
Export the endpoint PUT /{resource}/{pk}
.
class UpdateView(Resource):
schema: Type[BaseModel]
DeleteView
Export the endpoint DELETE /{resource}/{pk}
.
class DeleteView(Resource):
pass
Reference
You can see the examples here.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fastapi-rest-0.1.0.tar.gz
(7.2 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_rest-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d52e6deebf7fd9a30605d13537adcfa314203526c433be0489e44497af6b5c12 |
|
MD5 | 688988a55521b80a80c99d981bac6b7b |
|
BLAKE2b-256 | bfded1afcf2c9ce9397e3ef1be47d7e022bf1d310d08a53a0c78cb1ab81dfe7b |