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
query: Optional[Type[BaseModel]] = 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 Apache2.0 License.
Metadata
Release files for fastapi-rest 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi-rest-0.1.1.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_rest-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.0 kB
Release files / fastapi-rest-0.1.1.tar.gz
| Download URL | fastapi-rest-0.1.1.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c85cc2dc889ebddaa594a1aad4840e9445559f70c18e6a28a920643bd14ab482
|
|
BLAKE2b-256 checksum How to use checksums |
c978741df2d872ed73799bbc58f7444bd143cea17ce2752d862c62e301e3c26f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
|
Release files / fastapi_rest-0.1.1-py3-none-any.whl
| Download URL | fastapi_rest-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47943005eb86eaa98c07f2026479e4225cbe8d0e817596aa8ef6ac94f345dd6f
|
|
BLAKE2b-256 checksum How to use checksums |
bf525ee0cac819299feb66e07fff2be09fbbe48ebcfb0f4857c91b2c898246e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
|