Flask-Rich


NameFlask-Rich JSON
Version 0.4.1 PyPI version JSON
download
home_pagehttps://github.com/zyf722/Flask-Rich
SummaryRich implementation for Flask
upload_time2023-11-14 12:29:25
maintainerMaxMixAlex
docs_urlNone
authorBD103
requires_python>=3.8,<4.0
licenseMIT
keywords flask extension rich
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            > [!NOTE]
> **This repository is an official fork of the original [BD103/Flask-Rich](https://github.com/BD103/Flask-Rich) project.** All releases after 0.3 will be published from this fork.
---

[![License](https://img.shields.io/github/license/zyf722/Flask-Rich)](LICENSE)
[![PyPI version](https://img.shields.io/pypi/v/flask-rich
)](https://pypi.org/project/flask-rich/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/flask-rich)
[![Documentation Status](https://readthedocs.org/projects/flask-rich/badge/?version=latest)](https://flask-rich.readthedocs.io/en/latest/?badge=latest)


# Flask-Rich

Flask-Rich is a Flask extension that implements the [Rich](https://pypi.org/project/rich/) programming library with [Flask](https://pypi.org/project/Flask/), which brings better logging / tracebacks with *rich* text formatting, and more features related to the console.

[![asciicast](https://asciinema.org/a/608190.svg)](https://asciinema.org/a/608190)

## Features

- :rainbow: Better console logging powered by [Rich's logging](https://rich.readthedocs.io/en/latest/logging.html) handler, with full support for [console markup](https://rich.readthedocs.io/en/latest/markup.html#console-markup), [highlighting](https://rich.readthedocs.io/en/latest/highlighting.html),  [tracebacks](https://rich.readthedocs.io/en/latest/traceback.html) and more
- :construction: Builtin support for [Werkzeug](https://pypi.org/project/Werkzeug/) which runs the Flask development server
- :mag: A new `rich-routes` Flask command that use Rich to show all routes
- :wrench: 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

```python
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

```python
# rich.py
from flask_rich import RichApplication

# Initialize the extension without an app
rich = RichApplication()
```

```python
# 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](https://flask-rich.readthedocs.io/en/latest/).

## Feedback

If you have any suggestions or troubles using this extension, please feel free to open an [issue](https://github.com/zyf722/Flask-Rich/issues).

## Contributing

[Pull Requests](https://github.com/zyf722/Flask-Rich/pulls) are welcome!

You can setup your own copy of the source code with Git and [Poetry](https://python-poetry.org/):

```shell
# 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](https://www.conventionalcommits.org/en/v1.0.0/) specification when writing commit messages and creating pull requests.

## Credits
Thanks to the following people for their contributions:
- [BD103](https://github.com/BD103) for creating the original project and maintaining it until version `0.3.1`
- [Will McGugan](https://github.com/willmcgugan) and all other contributors of the [Rich](https://github.com/Textualize/rich) project
- [Pallets](https://github.com/pallets) and all other contributors of the [Flask](https://github.com/pallets/flask) project
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zyf722/Flask-Rich",
    "name": "Flask-Rich",
    "maintainer": "MaxMixAlex",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "MaxMixAlex@protonmail.com",
    "keywords": "flask,extension,rich",
    "author": "BD103",
    "author_email": "dont@stalk.me",
    "download_url": "https://files.pythonhosted.org/packages/9a/ec/4c53cd784bd4a97813b18469dca1755b70e824d23e63616e7edac6f51e07/flask_rich-0.4.1.tar.gz",
    "platform": null,
    "description": "> [!NOTE]\n> **This repository is an official fork of the original [BD103/Flask-Rich](https://github.com/BD103/Flask-Rich) project.** All releases after 0.3 will be published from this fork.\n---\n\n[![License](https://img.shields.io/github/license/zyf722/Flask-Rich)](LICENSE)\n[![PyPI version](https://img.shields.io/pypi/v/flask-rich\n)](https://pypi.org/project/flask-rich/)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/flask-rich)\n[![Documentation Status](https://readthedocs.org/projects/flask-rich/badge/?version=latest)](https://flask-rich.readthedocs.io/en/latest/?badge=latest)\n\n\n# Flask-Rich\n\nFlask-Rich is a Flask extension that implements the [Rich](https://pypi.org/project/rich/) programming library with [Flask](https://pypi.org/project/Flask/), which brings better logging / tracebacks with *rich* text formatting, and more features related to the console.\n\n[![asciicast](https://asciinema.org/a/608190.svg)](https://asciinema.org/a/608190)\n\n## Features\n\n- :rainbow: Better console logging powered by [Rich's logging](https://rich.readthedocs.io/en/latest/logging.html) handler, with full support for [console markup](https://rich.readthedocs.io/en/latest/markup.html#console-markup), [highlighting](https://rich.readthedocs.io/en/latest/highlighting.html),  [tracebacks](https://rich.readthedocs.io/en/latest/traceback.html) and more\n- :construction: Builtin support for [Werkzeug](https://pypi.org/project/Werkzeug/) which runs the Flask development server\n- :mag: A new `rich-routes` Flask command that use Rich to show all routes\n- :wrench: Customizable and toggleable features\n\n\n## Basic Usage\n\nJust like any other Flask extension, you can initialize and register Flask-Rich with your Flask app in two ways:\n\n### Single File\n\n```python\nfrom flask import Flask\nfrom flask_rich import RichApplication\n\nclass Config:\n    RICH_LOGGING = True\n\napp = Flask(__name__)\napp.config.from_object(Config())  # or any other way to load config\n\n# Initialize the extension with the app\nrich = RichApplication(app)\n\n@app.route(\"/\")\ndef index():\n    return \"Hello World!\"\n```\n\n### Factory Pattern\n\n```python\n# rich.py\nfrom flask_rich import RichApplication\n\n# Initialize the extension without an app\nrich = RichApplication()\n```\n\n```python\n# app.py\nfrom flask import Flask\nfrom .rich import rich\n\nclass Config:\n    RICH_LOGGING = True\n\ndef create_app:\n    app = Flask(__name__)\n    app.config.from_object(Config())  # or any other way to load config\n\n    # Register the extension with the app\n    rich.init_app(app)\n    # ...\n    return app\n```\n\nAfter registering, the `RichApplication` class shall do all the work for you.\n\nYou can now use the `app.logger` object to log rich text, and use the `flask rich-routes` command to show all routes.\n\nFor further usage and configuration, please refer to the [documentation](https://flask-rich.readthedocs.io/en/latest/).\n\n## Feedback\n\nIf you have any suggestions or troubles using this extension, please feel free to open an [issue](https://github.com/zyf722/Flask-Rich/issues).\n\n## Contributing\n\n[Pull Requests](https://github.com/zyf722/Flask-Rich/pulls) are welcome!\n\nYou can setup your own copy of the source code with Git and [Poetry](https://python-poetry.org/):\n\n```shell\n# Git\ngit clone https://github.com/zyf722/Flask-Rich.git\ncd Flask-Rich/\n\n# Poetry\npoetry lock\npoetry install\npoetry shell\n```\n\nIt is strongly recommended to follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification when writing commit messages and creating pull requests.\n\n## Credits\nThanks to the following people for their contributions:\n- [BD103](https://github.com/BD103) for creating the original project and maintaining it until version `0.3.1`\n- [Will McGugan](https://github.com/willmcgugan) and all other contributors of the [Rich](https://github.com/Textualize/rich) project\n- [Pallets](https://github.com/pallets) and all other contributors of the [Flask](https://github.com/pallets/flask) project",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Rich implementation for Flask",
    "version": "0.4.1",
    "project_urls": {
        "Documentation": "https://flask-rich.readthedocs.io",
        "Homepage": "https://github.com/zyf722/Flask-Rich",
        "Repository": "https://github.com/zyf722/Flask-Rich"
    },
    "split_keywords": [
        "flask",
        "extension",
        "rich"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8f86b1c5a8087a8fe7a746815168ef7efdd40c0c7b1881f454976d1d979a119d",
                "md5": "f091524da1780c7cadc68019630db9e0",
                "sha256": "cac98f8dcc8bc2cfc33c82db189f4a1272209322c8f0db864383f61a144389a4"
            },
            "downloads": -1,
            "filename": "flask_rich-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f091524da1780c7cadc68019630db9e0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 5877,
            "upload_time": "2023-11-14T12:29:23",
            "upload_time_iso_8601": "2023-11-14T12:29:23.700127Z",
            "url": "https://files.pythonhosted.org/packages/8f/86/b1c5a8087a8fe7a746815168ef7efdd40c0c7b1881f454976d1d979a119d/flask_rich-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9aec4c53cd784bd4a97813b18469dca1755b70e824d23e63616e7edac6f51e07",
                "md5": "d30cc580e000604f995e0a3f0d78a640",
                "sha256": "7e3aee25fb83033bb11a876ab14078f04709b9a98ccf4a14106d704781b55ed1"
            },
            "downloads": -1,
            "filename": "flask_rich-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d30cc580e000604f995e0a3f0d78a640",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 5406,
            "upload_time": "2023-11-14T12:29:25",
            "upload_time_iso_8601": "2023-11-14T12:29:25.098187Z",
            "url": "https://files.pythonhosted.org/packages/9a/ec/4c53cd784bd4a97813b18469dca1755b70e824d23e63616e7edac6f51e07/flask_rich-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-14 12:29:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zyf722",
    "github_project": "Flask-Rich",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "flask-rich"
}
        
Elapsed time: 0.14390s