flask-sugar-0.0.9
توضیحات
Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | flask-sugar-0.0.9 |
| نام | flask-sugar |
| نسخه کتابخانه | 0.0.9 |
| نگهدارنده | ['shangsky'] |
| ایمیل نگهدارنده | ['t_c_y@outlook.com'] |
| نویسنده | shangsky |
| ایمیل نویسنده | t_c_y@outlook.com |
| آدرس صفحه اصلی | https://github.com/shangsky/flask-sugar |
| آدرس اینترنتی | https://pypi.org/project/flask-sugar/ |
| مجوز | MIT |
# Flask Sugar
- [简体中文](README_zh.md)
Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints.
check parameters and generate API documents automatically
Documentation: <https://shangsky.github.io/flask-sugar> or <https://flask-sugar.vercel.app/>
Source Code: <https://github.com/shangsky/flask-sugar>
## Requirements
- Python 3.6+
- Flask 2.0+
## Installation
```shell
$ pip install flask-sugar
```
## Example
```python
# save this as app.py
from flask_sugar import Sugar, Header
from pydantic import BaseModel
app = Sugar(__name__)
class Item(BaseModel):
name: str
size: int
class Resp(BaseModel):
a: int
b: str
c: str
item: Item
@app.post("/item/<a>")
def demo(
a: int, # path param
item: Item, # json body param
b: str = "default_query_param_b", # query param
c: str = Header("default_header_param_b"), # request header param
) -> Resp:
"""demo page"""
return Resp(a=a, b=b, c=c, item=item)
```
```shell
$ flask run --reload
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
```
Now visit the API documentation with Swagger UI at http://localhost:5000/doc:

visit the API documentation with Redoc at http://localhost:5000/redoc:

## License
This project is licensed under the terms of the MIT license.
نیازمندی
| مقدار | نام |
|---|---|
| >=2.0 | flask |
| <2.0.0,>=1.8 | pydantic |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl flask-sugar-0.0.9:
pip install flask-sugar-0.0.9.whl
نصب پکیج tar.gz flask-sugar-0.0.9:
pip install flask-sugar-0.0.9.tar.gz