This repository was archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
46 lines (35 loc) · 1.16 KB
/
app.py
File metadata and controls
46 lines (35 loc) · 1.16 KB
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
from flask import Flask
from flask_login import LoginManager
from routes import *
from Config.ConfigManager import ConfigManager
app = Flask(__name__)
login_manager = LoginManager()
login_manager.init_app(app)
config_manager = ConfigManager()
config = config_manager.get_config()
app.config.update(TESTING=True, SECRET_KEY='192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf')
app.register_blueprint(routes)
@login_manager.user_loader
def load_user(user_id):
dbUser = DBUser.Database()
# Retrieve the user from the database using the provided user_id
user_data = dbUser.get_user_by_id(user_id)
# print("User_loader is running")
# print(user_data)
if user_data:
return User(user_data[0])
return None
# Error Site Route
@app.route('/404')
def error404():
return render_template('404.html'), 404
# Error handling page for not found sites / locations
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
if __name__ == '__main__':
app.run(
host=config.get('FLASK', 'HOST'),
port=int(config.get('FLASK', 'PORT')),
debug=bool(config.get('FLASK', 'DEBUG'))
)