flask-favicon


Nameflask-favicon JSON
Version 0.1.4 PyPI version JSON
download
home_page
SummaryFlask extension to handle favicons.
upload_time2023-11-20 02:13:55
maintainer
docs_urlNone
authorMaxime Dupuis
requires_python>=3.7
licensegpl-3.0
keywords
VCS
bugtrack_url
requirements flask pytest pytest-cov Pillow
Travis-CI No Travis.
coveralls test coverage
            [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/flask-favicon.svg)](https://pypi.python.org/pypi/flask-favicon/)
[![Platforms](https://img.shields.io/badge/platform-Linux,_MacOS,_Windows-blue)]()
[![PyPI version fury.io](https://badge.fury.io/py/flask-favicon.svg)](https://pypi.python.org/pypi/flask-favicon/)
[![GitHub Workflow Status (with event)](https://github.com/maxdup/flask-favicon/actions/workflows/CI.yml/badge.svg)]()
[![Coverage](https://github.com/maxdup/flask-favicon/blob/main/docs/source/coverage.svg "coverage")]()

# Flask-favicon


Flask-favicon is a [Flask](https://flask.palletsprojects.com) extension which generates multiple favicon variants for different platforms. The goal is to cover as many devices as possible from a single image file. Flask-favicon serves all the assets for you and provides an easy to use Jinga template which you can include in your html `<head>`.

Full Documentation: https://maxdup.github.io/flask-favicon/


## Installation

Flask-favicon is available on the Python Package Index. This makes installing it with pip as easy as:

```bash
pip install flask-favicon
```



Initializing
------------

The extension needs to be loaded alongside your Flask application. All favicons need to be declared during app creation with `register_favicon()`. You may register any amount of favicons. You should have at least one favicon named as `'default'`

Here's a minimal example of how this is done:

```python
    from flask import Flask, Blueprint
    from flask_favicon import FlaskFavicon

    flaskFavicon = FlaskFavicon()

    app = Flask('my-app')

    bp = Blueprint('my-blueprint', __name__)
    app.register_blueprint(bp)

    flaskFavicon.init_app(app)
    flaskFavicon.register_favicon('source/favicon.png', 'default') # filename, favicon identifier
    flaskFavicon.register_favicon('source/favicon-alt.png', 'default-alt')
    flaskFavicon.register_favicon('source/promo.png', 'promo')

    app.run()
```


Usage
-----

Initiallizing `FlaskFavicon` provides you with a Jinga template to be inserted in your `<head>`.

```html
<!-- _head.html -->
<head>
    ...
    {% include "flask-favicon.html" %}
    ...
</head>
```

By default, the `flask-favicon.html` template will be populated with the favicon registered as `'default'`.

To use the alternative favicons as declared earlier, you can use Flask-favicon's `use_favicon` decorator alongside route declarations.

```python

   from flask import Blueprint, render_template
   from flask_favicon import use_favicon

   bp_site = Blueprint('site', __name__)

   @bp_site.route("/")
   # will use 'default' favicon
   def index():
       return render_template('index.html')

   @bp_site.route("/promo")
   @use_favicon('promo')
   def promo():
       return render_template('promo-page.html')

   @bp_site.route("/special-event")
   @use_favicon('default-alt')
   def special_event():
       return render_template('special-page.html')
```

> **_NOTE:_** `@use_favicon()` comes after the `@bp.route()` decorator.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "flask-favicon",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Maxime Dupuis",
    "author_email": "mdupuis@hotmail.ca",
    "download_url": "https://files.pythonhosted.org/packages/15/34/26b316b187b9dc1179a10e4292b16b351a4d38c91f6e7310c8a48e1bc9f2/flask-favicon-0.1.4.tar.gz",
    "platform": "any",
    "description": "[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/flask-favicon.svg)](https://pypi.python.org/pypi/flask-favicon/)\n[![Platforms](https://img.shields.io/badge/platform-Linux,_MacOS,_Windows-blue)]()\n[![PyPI version fury.io](https://badge.fury.io/py/flask-favicon.svg)](https://pypi.python.org/pypi/flask-favicon/)\n[![GitHub Workflow Status (with event)](https://github.com/maxdup/flask-favicon/actions/workflows/CI.yml/badge.svg)]()\n[![Coverage](https://github.com/maxdup/flask-favicon/blob/main/docs/source/coverage.svg \"coverage\")]()\n\n# Flask-favicon\n\n\nFlask-favicon is a [Flask](https://flask.palletsprojects.com) extension which generates multiple favicon variants for different platforms. The goal is to cover as many devices as possible from a single image file. Flask-favicon serves all the assets for you and provides an easy to use Jinga template which you can include in your html `<head>`.\n\nFull Documentation: https://maxdup.github.io/flask-favicon/\n\n\n## Installation\n\nFlask-favicon is available on the Python Package Index. This makes installing it with pip as easy as:\n\n```bash\npip install flask-favicon\n```\n\n\n\nInitializing\n------------\n\nThe extension needs to be loaded alongside your Flask application. All favicons need to be declared during app creation with `register_favicon()`. You may register any amount of favicons. You should have at least one favicon named as `'default'`\n\nHere's a minimal example of how this is done:\n\n```python\n    from flask import Flask, Blueprint\n    from flask_favicon import FlaskFavicon\n\n    flaskFavicon = FlaskFavicon()\n\n    app = Flask('my-app')\n\n    bp = Blueprint('my-blueprint', __name__)\n    app.register_blueprint(bp)\n\n    flaskFavicon.init_app(app)\n    flaskFavicon.register_favicon('source/favicon.png', 'default') # filename, favicon identifier\n    flaskFavicon.register_favicon('source/favicon-alt.png', 'default-alt')\n    flaskFavicon.register_favicon('source/promo.png', 'promo')\n\n    app.run()\n```\n\n\nUsage\n-----\n\nInitiallizing `FlaskFavicon` provides you with a Jinga template to be inserted in your `<head>`.\n\n```html\n<!-- _head.html -->\n<head>\n    ...\n    {% include \"flask-favicon.html\" %}\n    ...\n</head>\n```\n\nBy default, the `flask-favicon.html` template will be populated with the favicon registered as `'default'`.\n\nTo use the alternative favicons as declared earlier, you can use Flask-favicon's `use_favicon` decorator alongside route declarations.\n\n```python\n\n   from flask import Blueprint, render_template\n   from flask_favicon import use_favicon\n\n   bp_site = Blueprint('site', __name__)\n\n   @bp_site.route(\"/\")\n   # will use 'default' favicon\n   def index():\n       return render_template('index.html')\n\n   @bp_site.route(\"/promo\")\n   @use_favicon('promo')\n   def promo():\n       return render_template('promo-page.html')\n\n   @bp_site.route(\"/special-event\")\n   @use_favicon('default-alt')\n   def special_event():\n       return render_template('special-page.html')\n```\n\n> **_NOTE:_** `@use_favicon()` comes after the `@bp.route()` decorator.\n",
    "bugtrack_url": null,
    "license": "gpl-3.0",
    "summary": "Flask extension to handle favicons.",
    "version": "0.1.4",
    "project_urls": {
        "Documentation": "https://maxdup.github.io/flask-favicon/",
        "Github": "https://github.com/maxdup/flask-favicon"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ab85c9670642c562a125ae4b91b0640fa25911ca04daf68039d1f06a54973577",
                "md5": "9e5797223c9054d3c734837581c71c8e",
                "sha256": "9feb82917299f46aef840a9bb1ce7acb904786c65d2b3bff68e012c8e9442504"
            },
            "downloads": -1,
            "filename": "flask_favicon-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e5797223c9054d3c734837581c71c8e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 24100,
            "upload_time": "2023-11-20T02:13:54",
            "upload_time_iso_8601": "2023-11-20T02:13:54.474664Z",
            "url": "https://files.pythonhosted.org/packages/ab/85/c9670642c562a125ae4b91b0640fa25911ca04daf68039d1f06a54973577/flask_favicon-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "153426b316b187b9dc1179a10e4292b16b351a4d38c91f6e7310c8a48e1bc9f2",
                "md5": "dd7d21877587f5d097e0dee1a599ac45",
                "sha256": "8ad7110fc5b9f885fc368334a56de9b8b1f757897aed3b07439a0d28a798d202"
            },
            "downloads": -1,
            "filename": "flask-favicon-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "dd7d21877587f5d097e0dee1a599ac45",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 22130,
            "upload_time": "2023-11-20T02:13:55",
            "upload_time_iso_8601": "2023-11-20T02:13:55.884631Z",
            "url": "https://files.pythonhosted.org/packages/15/34/26b316b187b9dc1179a10e4292b16b351a4d38c91f6e7310c8a48e1bc9f2/flask-favicon-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-20 02:13:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maxdup",
    "github_project": "flask-favicon",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "flask",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "pytest-cov",
            "specs": []
        },
        {
            "name": "Pillow",
            "specs": []
        }
    ],
    "tox": true,
    "lcname": "flask-favicon"
}
        
Elapsed time: 0.13872s