-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.py
50 lines (37 loc) · 1.36 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
from flask import Flask
# Blueprints Imports
from blueprints.page import page
from blueprints.users import user
from blueprints.questions import aos_test, elective_course
# extensions Import
from extensions import mail, csrf, login_manager
CELERY_TASK_LIST = ['blueprints.contact.tasks', ]
# app = Flask(__name__, instance_relative_config=True)
# app.config.from_object('config.settings')
# app.config.from_pyfile('settings.py', silent=True)
#
# app.register_blueprint(page)
def create_app(settings_override=None):
"""
Create a Flask application using the app factory pattern.
:param settings_override: Override settings
:return: Flask app
"""
application = Flask(__name__, instance_relative_config=True)
application.config.from_object('config.settings')
application.config.from_pyfile('settings.py', silent=True)
if settings_override:
application.config.update(settings_override)
application.register_blueprint(page)
application.register_blueprint(user)
application.register_blueprint(aos_test)
application.register_blueprint(elective_course)
extensions(application)
return application
def extensions(our_app):
mail.init_app(our_app)
csrf.init_app(our_app)
login_manager.init_app(our_app)
login_manager.login_view = 'user.login'
login_manager.login_message_category = 'info'
return None