__init__.py 880 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

Pierre Dittgen's avatar
wip  
Pierre Dittgen committed
8
#import validata_core
9 10 11

# Let this import after app initialisation
from . import config
Pierre Dittgen's avatar
wip  
Pierre Dittgen committed
12
#from .validate_helper import ValidatorHelper
13 14

# Schemas settings
Pierre Dittgen's avatar
wip  
Pierre Dittgen committed
15 16 17 18
# schemas_config = validata_core.get_schemas_config()
# ValidatorHelper.init(schemas_config)
# TODO: load config.toml

19 20

# Flask things
21
app = flask.Flask(__name__)
22 23
app.secret_key = config.SECRET_KEY

24

25 26 27 28
# 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__)

29

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


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