__init__.py 848 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
import validata_core
9 10 11 12

# Let this import after app initialisation
from . import config
from .validate_helper import ValidatorHelper
13 14

# Schemas settings
Pierre Dittgen's avatar
Pierre Dittgen committed
15
schemas_config = validata_core.get_schemas_config()
Christophe Benz's avatar
Christophe Benz committed
16
ValidatorHelper.init(schemas_config)
17 18

# Flask things
19
app = flask.Flask(__name__)
20 21
app.secret_key = config.SECRET_KEY

22

23 24 25 26
# 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__)

27

28 29 30 31 32 33
@jinja2.contextfilter
@blueprint.app_template_filter()
def urlencode(context, value):
    return quote_plus(value)


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