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
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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi-rest-0.1.1.tar.gz.
File metadata
- Download URL: fastapi-rest-0.1.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c85cc2dc889ebddaa594a1aad4840e9445559f70c18e6a28a920643bd14ab482
|
|
| MD5 |
9bae6e811f3d6372c997bc80fff4af5c
|
|
| BLAKE2b-256 |
c978741df2d872ed73799bbc58f7444bd143cea17ce2752d862c62e301e3c26f
|
File details
Details for the file fastapi_rest-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_rest-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47943005eb86eaa98c07f2026479e4225cbe8d0e817596aa8ef6ac94f345dd6f
|
|
| MD5 |
3e87d4fe1cbed54338530a6b3bbc01aa
|
|
| BLAKE2b-256 |
bf525ee0cac819299feb66e07fff2be09fbbe48ebcfb0f4857c91b2c898246e1
|