Metadata-Version: 2.1
Name: flask-gun
Version: 1.0.0
Summary: Flask Gun is a web framework for building APIs with Flask and Python 3.10+ type hints.
Author: Wumao
Author-email: 549240290@qq.com
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: Flask (>=2.3.0)
Requires-Dist: docstring-parser (>=0.14.1,<0.15.0)
Requires-Dist: pydantic (>=2.4.2,<3.0.0)
Description-Content-Type: text/markdown

# Flask Gun

![build](https://github.com/kiwicom/flask-ninja/workflows/Build%20jobs/badge.svg)
![python](https://img.shields.io/badge/Python-3.9%20|%203.10-blue)

**Flask Gun** is a web framework for building APIs with Flask and Python 3.9+ type hints.

**Derived from Flask ninja 1.3.0 fork**

Key features:

- Easy: Designed to be easy to use and intuitive.
- Fast to code: Type hints and automatic docs lets you focus only on business logic.
- Standards-based: Based on the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.
- Models based: Pydantic models support and automatic (de)serialization of requests/responses.
- Secure: Natively supports various authentication methods for the requests.

For mode details, see the [Documentation](https://flask-ninja.readthedocs.io/en/latest/)

## Installation

```
pip install flask-gun
```

## Usage

In your flask project where you create flask app:

```Python
from flask import Flask
from flask_gun import GunAPI
from pydantic import BaseModel

app = Flask(__name__)
api = GunAPI(app)

class Response(BaseModel):
    """Response model containing results of various number operations."""
    sum: int
    difference: int
    product: int
    power: int

@api.get("/compute")
def compute(a: int, b: int) -> Response:
    """Computes results of various number operations.

    This endpoint returns a result of the following operations:
    - sum
    - difference
    - product
    - power

    :param int a: First number
    :param int b: Second number number
    """
    return Response(
        sum=a + b,
        difference=a - b,
        product=a * b,
        power=a ** b
    )

if __name__ == "__main__":
    app.run()
```

**That's it !**

Now you've just created an API that:

- receives an HTTP GET request at `/compute`
- takes, validates and type-casts GET parameters `a` and `b`
- validates the returned Response object and serializes it into JSON
- generates an OpenAPI schema for defined operation

### Interactive API docs

Now go to <a href="http://127.0.0.1:8000/docs" target="_blank">http://127.0.0.1:5000/docs</a>

You will see the automatic interactive API documentation (provided by <a href="https://github.com/swagger-api/swagger-ui" target="_blank">Swagger UI</a>):

