-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
67 lines (55 loc) · 2.04 KB
/
app.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import logging
import persistence
from logging.handlers import RotatingFileHandler
from flask import Flask, render_template
import blueprints.security
import blueprints.pages
import blueprints.users
import blueprints.schools
import blueprints.categories
import blueprints.languages
import blueprints.teams
import blueprints.messages
import security
from flask_wtf.csrf import CSRFProtect
from config import Config
from flask_minify import Minify
from jinja2 import Environment, PackageLoader, select_autoescape, FileSystemLoader
from blueprints.pages import init_error_handlers
from custom_filters import safe_escape
from flask_ckeditor import CKEditor
csrf = CSRFProtect()
minify = Minify(html=True, js=True, cssless=True)
ckeditor = CKEditor()
def create_app(config_class=Config):
app = Flask(__name__)
app.config.from_object(config_class)
app.jinja_env.filters['safe_escape'] = safe_escape
app.jinja_env.add_extension('jinja2.ext.do')
app.config['SQLALCHEMY_ENGINE_OPTIONS'] = {
'pool_size': 10,
'max_overflow': 20,
'pool_timeout': 30,
'pool_recycle': 1800,
}
persistence.init_app(app)
security.init_app(app)
csrf.init_app(app)
minify.init_app(app)
init_error_handlers(app)
ckeditor.init_app(app)
app.register_blueprint(blueprints.pages.bp, url_prefix='/')
app.register_blueprint(blueprints.security.bp, url_prefix='/')
app.register_blueprint(blueprints.users.bp, url_prefix='/users')
app.register_blueprint(blueprints.schools.bp, url_prefix='/schools')
app.register_blueprint(blueprints.teams.bp, url_prefix='/teams')
app.register_blueprint(blueprints.categories.bp, url_prefix='/categories')
app.register_blueprint(blueprints.languages.bp, url_prefix='/languages')
app.register_blueprint(blueprints.messages.bp, url_prefix='/messages')
handler = RotatingFileHandler('errors.log')
handler.setLevel(logging.ERROR)
app.logger.addHandler(handler)
return app
if __name__ == '__main__':
create_app().run(host="0.0.0.0", debug=True)