-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
54 lines (36 loc) · 1.3 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
from flask import Flask
from flask_debugtoolbar import DebugToolbarExtension
from flask_login import LoginManager
from flask_mail import Mail
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import CSRFProtect
from config import config
db = SQLAlchemy()
csrf = CSRFProtect()
mail = None
toolbar = None
login_manager = LoginManager()
login_manager.login_view = 'auth.signup'
login_manager.login_message = ""
def create_app(config_key: str):
global mail, toolbar
app = Flask(__name__)
app.config.from_object(config[config_key])
print(" * Running app as " + config_key + " mode <--")
# === Init Extensions ===
csrf.init_app(app)
db.init_app(app)
login_manager.init_app(app)
mail = Mail(app)
toolbar = DebugToolbarExtension(app)
Migrate(app, db)
from apps.contact import views as contact_views
app.register_blueprint(contact_views.contact, url_prefix='/contact')
from apps.crud import views as crud_views
app.register_blueprint(crud_views.crud, url_prefix='/crud')
from apps.auth import views as auth_views
app.register_blueprint(auth_views.auth, url_prefix='/auth')
from apps.detector import views as detector_views
app.register_blueprint(detector_views.dt, url_prefix='/detector')
return app