Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/seluj78/flask-utils

Various Flask utilities that I find useful in my projects
https://github.com/seluj78/flask-utils

flask hacktoberfest python utility

Last synced: 2 months ago
JSON representation

Various Flask utilities that I find useful in my projects

Awesome Lists containing this project

README

        

[![Documentation Status](https://readthedocs.org/projects/flask-utils/badge/?version=latest)](https://flask-utils.readthedocs.io/en/latest/?badge=latest)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/Seluj78/flask-utils)
![GitHub commits since latest release](https://img.shields.io/github/commits-since/seluj78/flask-utils/latest)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/seluj78/flask-utils/tests.yml?label=tests)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/seluj78/flask-utils/linting.yml?label=linting)
![GitHub License](https://img.shields.io/github/license/seluj78/flask-utils)
[![All Contributors](https://img.shields.io/github/all-contributors/seluj78/flask-utils?color=ee8449&style=flat-square)](#contributors)
[![codecov](https://codecov.io/gh/Seluj78/flask-utils/graph/badge.svg?token=ChUOweAp4b)](https://codecov.io/gh/Seluj78/flask-utils)

[//]: # (TODO: Uncomment when flask-utils had been freed from pypi)
[//]: # (![PyPI - Downloads](https://img.shields.io/pypi/dm/flask-utils))
[//]: # (![PyPI - Implementation](https://img.shields.io/pypi/implementation/flask-utils))
[//]: # (![PyPI - Python Version](https://img.shields.io/pypi/pyversions/flask-utils))
[//]: # (![PyPI - Versions from Framework Classifiers](https://img.shields.io/pypi/frameworkversions/:frameworkName/flask-utils))
[//]: # (![PyPI - Wheel](https://img.shields.io/pypi/wheel/flask-utils))
[//]: # (![PyPI - Version](https://img.shields.io/pypi/v/flask-utils))

# Flask-Utils

A collection of useful Flask utilities I use every day in my Flask projects.

## Installation

```bash
pip install flask-utils
```

## Usage

```python
from flask import Flask
from flask_utils import FlaskUtils
from flask_utils import BadRequestError

app = Flask(__name__)
utils = FlaskUtils(app, register_error_handlers=True)

@app.route('/')
def index():
raise BadRequestError
```

```python
from typing import List, Optional
from flask import Flask
from flask_utils import validate_params

app = Flask(__name__)

@app.post('/create-user')
@validate_params({"first_name": str, "last_name": str, "age": Optional[int], "hobbies": List[str]})
def create_user():
# ...
# This will enforce the following rules:
# - first_name and last_name must be strings and are required
# - age is optional and must be an integer
# - hobbies is a list of strings
# This is just an example, you can use any type of validation you want
return "User created"
```

## Documentation

You can find the full documentation at [Read the Docs](https://flask-utils.readthedocs.io/en/latest/)

## Testing

Install uv
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

Run the tests
```bash
uv run tox
```

OR

Run the tests in a multithreaded fashion
```bash
uv run tox -p
```

## Contributors



Jules Lasne
Jules Lasne

💻 📖 🚇 💡 🧑‍🏫 📦 📆 👀
Mews
Mews

📖
Julien Palard
Julien Palard

🤔






Add your contributions