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: 9 months ago
JSON representation
Various Flask utilities that I find useful in my projects
- Host: GitHub
- URL: https://github.com/seluj78/flask-utils
- Owner: Seluj78
- License: gpl-3.0
- Created: 2024-06-09T08:40:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-04T16:57:42.000Z (about 1 year ago)
- Last Synced: 2024-11-04T17:45:49.091Z (about 1 year ago)
- Topics: flask, hacktoberfest, python, utility
- Language: Python
- Homepage:
- Size: 184 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# This project is archived
I've moved on to using FastAPI in my new company, and I don't feel the need to maintain this anymore
[](https://flask-utils.readthedocs.io/en/latest/?badge=latest)





[](#contributors)
[](https://codecov.io/gh/Seluj78/flask-utils)
[//]: # (TODO: Uncomment when flask-utils had been freed from pypi)
[//]: # ()
[//]: # ()
[//]: # ()
[//]: # ()
[//]: # ()
[//]: # ()
# 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
💻 📖 🚇 💡 🧑🏫 📦 📆 👀 ✅

Mews
📖 ✅

Julien Palard
🤔
Add your contributions