Flask-Rich
Flask-Rich is a Flask extension that implements the Rich programming library with Flask, which brings better logging / tracebacks with rich text formatting, and more features related to the console.
Features
- 🌈 Better console logging powered by Rich's logging handler, with full support for console markup, highlighting, tracebacks and more
- 🚧 Builtin support for Werkzeug which runs the Flask development server
- 🔍 A new
rich-routesFlask command that use Rich to show all routes - 🔧 Customizable and toggleable features
Basic Usage
Just like any other Flask extension, you can initialize and register Flask-Rich with your Flask app in two ways:
Single File
from flask import Flask
from flask_rich import RichApplication
class Config:
RICH_LOGGING = True
app = Flask(__name__)
app.config.from_object(Config()) # or any other way to load config
# Initialize the extension with the app
rich = RichApplication(app)
@app.route("/")
def index():
return "Hello World!"
Factory Pattern
# rich.py
from flask_rich import RichApplication
# Initialize the extension without an app
rich = RichApplication()
# app.py
from flask import Flask
from .rich import rich
class Config:
RICH_LOGGING = True
def create_app:
app = Flask(__name__)
app.config.from_object(Config()) # or any other way to load config
# Register the extension with the app
rich.init_app(app)
# ...
return app
After registering, the RichApplication class shall do all the work for you.
You can now use the app.logger object to log rich text, and use the flask rich-routes command to show all routes.
For further usage and configuration, please refer to the documentation.
Feedback
If you have any suggestions or troubles using this extension, please feel free to open an issue.
Contributing
Pull Requests are welcome!
You can setup your own copy of the source code with Git and Poetry:
# Git
git clone https://github.com/zyf722/Flask-Rich.git
cd Flask-Rich/
# Poetry
poetry lock
poetry install
poetry shell
It is strongly recommended to follow the Conventional Commits specification when writing commit messages and creating pull requests.
Credits
Thanks to the following people for their contributions:
- BD103 for creating the original project and maintaining it until version
0.3.1 - Will McGugan and all other contributors of the Rich project
- Pallets and all other contributors of the Flask project
Metadata
Release files for Flask-Rich 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| flask_rich-0.4.1.tar.gz | 5.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_rich-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.3 kB
Release files / flask_rich-0.4.1.tar.gz
| Download URL | flask_rich-0.4.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e3aee25fb83033bb11a876ab14078f04709b9a98ccf4a14106d704781b55ed1
|
|
BLAKE2b-256 checksum How to use checksums |
9aec4c53cd784bd4a97813b18469dca1755b70e824d23e63616e7edac6f51e07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.0 CPython/3.11.0 Linux/6.2.0-1015-azure
|
Release files / flask_rich-0.4.1-py3-none-any.whl
| Download URL | flask_rich-0.4.1-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cac98f8dcc8bc2cfc33c82db189f4a1272209322c8f0db864383f61a144389a4
|
|
BLAKE2b-256 checksum How to use checksums |
8f86b1c5a8087a8fe7a746815168ef7efdd40c0c7b1881f454976d1d979a119d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.0 CPython/3.11.0 Linux/6.2.0-1015-azure
|
Security for Flask-Rich 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.