__init__.py 699 Bytes
Newer Older
1
import os
2
from pathlib import Path
3
from urllib.parse import quote_plus
4

5 6
import flask
import jinja2
7

8 9
# Let this import after app initialisation
from . import config
10

Pierre Dittgen's avatar
wip  
Pierre Dittgen committed
11 12
# TODO: load config.toml

13 14

# Flask things
15
app = flask.Flask(__name__)
16 17
app.secret_key = config.SECRET_KEY

18

19 20 21 22
# Jinja2 url_quote_plus custom filter
# https://stackoverflow.com/questions/12288454/how-to-import-custom-jinja2-filters-from-another-file-and-using-flask
blueprint = flask.Blueprint('filters', __name__)

23

24 25 26 27 28 29
@jinja2.contextfilter
@blueprint.app_template_filter()
def urlencode(context, value):
    return quote_plus(value)


30 31
# Keep this import after app initialisation (to avoid cyclic imports)
from . import views  # isort:skip