Metadata-Version: 2.1
Name: flask-sugar
Version: 0.0.4
Summary: Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints.
Home-page: https://github.com/shangsky/flask-sugar
Author: shangsky
Author-email: t_c_y@outlook.com
Maintainer: shangsky
Maintainer-email: t_c_y@outlook.com
License: MIT
Platform: all
Classifier: Development Status :: 4 - Beta
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

# 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>

Source Code: <https://github.com/shangsky/flask-sugar>


## Requirements

- Python 3.6+
- Flask 2.0+

## Installation

```shell
$ pip install flask-sugar
```

## A Simple Example

```python
# save this as main.py
from typing import Any

from flask_sugar import Sugar
from typing_extensions import TypedDict

app = Sugar(__name__)


class Resp(TypedDict):
    code: int
    msg: str
    data: Any


@app.get("/")
def index() -> Resp:
    """index page"""
    return {"code": 0, "msg": "success", "data": {}}
```

```shell
$ export FLASK_APP=main:app
$ 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:

![](https://github.com/ShangSky/flask-sugar/raw/main/docs/img/swagger-ui.png)

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

![](https://github.com/ShangSky/flask-sugar/blob/main/docs/img/redoc.png)

## License

This project is licensed under the terms of the MIT license.

