No project description provided
Project description
Canonical Webteam Flask-Base
Flask extension that applies common configurations to all of webteam's flask apps.
Usage
from canonicalwebteam.flask_base.app import FlaskBase
app = FlaskBase(__name__, "app.name")
Or:
from canonicalwebteam.flask_base.app import FlaskBase
app = FlaskBase(
__name__,
"app.name",
template_404="404.html",
template_500="500.html",
favicon_url="/static/favicon.ico",
)
Features
Redirects and deleted paths
FlaskBase uses yaml-responses to allow easy configuration of redirects and return of deleted responses, by creating redirects.yaml
, permanent-redirects.yaml
and deleted.yaml
in the site root directory.
Error templates
FlaskBase
can optionally use templates to generate the 404
and 500
error responses:
app = FlaskBase(
__name__,
"app.name",
template_404="404.html",
template_500="500.html",
)
This will lead to e.g. http://localhost/non-existent-path
returning a 404
status with the contents of templates/404.html
.
Redirect /favicon.ico
FlaskBase
can optionally provide redirects for the commonly queried paths /favicon.ico
, /robots.txt
and /humans.txt
to sensible locations:
from canonicalwebteam.flask_base.app import FlaskBase
app = FlaskBase(
__name__,
"app.name",
template_404="404.html",
template_500="500.html",
favicon_url="/static/favicon.ico",
robots_url="/static/robots.txt",
humans_url="/static/humans.txt"
)
This will lead to e.g. http://localhost/favicon.ico
returning a 302
redirect to http://localhost/static/favicon.ico
.
robots.txt
and humans.txt
If you create a robots.txt
or humans.txt
in the root of your project, these will be served at /robots.txt
and /humans.txt
respectively.
Generating setup.py
In this project, for the time being, we maintain both a pyproject.toml
for Poetry and a setup.py
for traditional Python tooling. If you are developing on the module, you should update pyproject.toml
first and then regenerate the setup.py
using:
poetry install
poetry run poetry-setup
Tests
To run the tests execute poetry run python -m unittest discover tests
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for canonicalwebteam.flask_base-0.3.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60dfedd00b7b6a35e6ae31d769b51b298594acfcee29b41531460483cab9124d |
|
MD5 | 3a7c9d919e568c32fd2f8b982b9e3115 |
|
BLAKE2b-256 | 33c0c3a0138326fc0ccb83aeed7f0e222198ed1958cecb64d262b64e3156918d |
Hashes for canonicalwebteam.flask_base-0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fafb8d57b35591b899a31f7fc3518dd0b82a4afeb858ab53cf92e25920091a8 |
|
MD5 | 0c27e69df6c02379aec1863d1c7caa5a |
|
BLAKE2b-256 | ef85afeb0a6a126a8d761d5ca4c51cdd1d21f9af216289784888d08bbcbce3d4 |