-
Notifications
You must be signed in to change notification settings - Fork 12
/
__init__.py
33 lines (24 loc) · 844 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask import Flask, render_template
from flask_cors import CORS
from src.consts import NOT_FOUND
from src.routes.root import mod as root_mod
# We want to be flexible with regards to trailing slashes
class RelaxedFlask(Flask):
def add_url_rule(self, *args, **kwargs):
if 'strict_slashes' not in kwargs:
kwargs['strict_slashes'] = False
super(RelaxedFlask, self).add_url_rule(*args, **kwargs)
def create_flask_app():
app = RelaxedFlask(
__name__,
template_folder='../templates',
static_folder='../static',
static_url_path=''
)
app.config['CORS_HEADERS'] = 'Content-Type'
CORS(app)
app.register_blueprint(root_mod, url_prefix="/")
@app.errorhandler(404)
def not_found(e):
return render_template("404.html"), NOT_FOUND
return app