-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (28 loc) · 889 Bytes
/
app.py
File metadata and controls
38 lines (28 loc) · 889 Bytes
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
from flask import Flask
from dotenv import load_dotenv
import os
from extensions import bcrypt, login_manager
from models import User
from flask_wtf.csrf import CSRFProtect
def create_app():
"""Application Factory Function"""
load_dotenv()
app = Flask(
__name__,
static_folder='static',
template_folder='templates'
)
app.config['SECRET_KEY'] = os.getenv('FLASK_SECRET_KEY')
csrf = CSRFProtect(app)
bcrypt.init_app(app)
login_manager.init_app(app)
login_manager.login_view = 'auth.login'
login_manager.login_message_category = 'info'
@login_manager.user_loader
def load_user(user_id):
return User.get(user_id)
from auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint)
from routes import main as main_blueprint
app.register_blueprint(main_blueprint)
return app