fastapi-rest-0.1.1
توضیحات
Fast restful API based on FastAPI and TortoiseORM
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | fastapi-rest-0.1.1 |
| نام | fastapi-rest |
| نسخه کتابخانه | 0.1.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | long2ice |
| ایمیل نویسنده | long2ice@gmail.com |
| آدرس صفحه اصلی | https://github.com/long2ice/fastapi-rest |
| آدرس اینترنتی | https://pypi.org/project/fastapi-rest/ |
| مجوز | Apache2.0 |
# fastapi-rest
[](https://pypi.python.org/pypi/fastapi-rest)
[](https://github.com/long2ice/fastapi-rest)
[](https://github.com/long2ice/fastapi-rest/actions?query=workflow:pypi)
[](https://github.com/long2ice/fastapi-rest/actions?query=workflow:ci)
## Introduction
Fast restful API based on FastAPI and TortoiseORM.
## Install
```shell
pip install fastapi-rest
```
## Quick Start
First, define your `ListView` resource.
```python
from fastapi_rest.resource import ListView
class UserList(ListView):
model = User
fields = ("name", "age")
```
Second, include router to your app.
```python
app.include_router(UserList.as_router())
```
Now, you can visit the endpoint `/user` to get user list.
### ListView
Export the endpoint `GET /{resource}`.
```python
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}`.
```python
class DetailView(Resource):
fields: Optional[Tuple[str, ...]] = None
exclude: Optional[Tuple[str, ...]] = None
```
### CreateView
Export the endpoint `POST /{resource}`.
```python
class CreateView(Resource):
schema: Optional[Type[BaseModel]] = None
```
### UpdateView
Export the endpoint `PUT /{resource}/{pk}`.
```python
class UpdateView(Resource):
schema: Type[BaseModel]
```
### DeleteView
Export the endpoint `DELETE /{resource}/{pk}`.
```python
class DeleteView(Resource):
pass
```
## Reference
You can see the examples [here](./examples).
## License
This project is licensed under the [Apache2.0](https://github.com/long2ice/fastapi-rest/blob/master/LICENSE) License.
نیازمندی
| مقدار | نام |
|---|---|
| - | fastapi |
| - | tortoise-orm |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7,<4.0 | Python |
نحوه نصب
نصب پکیج whl fastapi-rest-0.1.1:
pip install fastapi-rest-0.1.1.whl
نصب پکیج tar.gz fastapi-rest-0.1.1:
pip install fastapi-rest-0.1.1.tar.gz