-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (27 loc) · 1.01 KB
/
main.py
File metadata and controls
39 lines (27 loc) · 1.01 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
from flask import Flask, render_template, request, redirect, url_for, session
from datetime import timedelta
from account.account import account, users_db
from home.home import home
from errors.errors_handling import errors_handling
app = Flask(__name__)
app.register_blueprint(account, url_prefix='/account')
app.register_blueprint(home, url_prefix='/home')
app.register_blueprint(errors_handling, url_prefix='/error')
app.secret_key = 'hello'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.sqlite3'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.permanent_session_lifetime = timedelta(days=30)
users_db.init_app(app)
@app.route('/')
def main():
if 'user' in session:
return redirect(url_for('home.homepage'))
else:
return redirect(url_for('account.login'))
@app.errorhandler(404)
def invalid_route(e):
return redirect(url_for('errors_handling.not_found_404'))
if __name__ == '__main__':
with app.app_context():
users_db.create_all()
app.run(host='0.0.0.0')