contentmatcher/app.py

68 lines
1.7 KiB
Python
Raw Normal View History

2022-08-16 10:44:13 +02:00
from flask import Flask, redirect, render_template, session, url_for
2022-04-25 00:32:17 +02:00
2022-05-20 00:01:56 +02:00
from auth import login_required, bp as auth_bp
from deck import bp as deck_bp
from menu import bp as menu_bp
from upload import bp as upload_bp
2023-04-08 23:39:36 +02:00
from import_link import bp as import_link_bp
2022-06-14 02:27:05 +02:00
from matches import bp as matches_bp
2022-06-23 14:41:11 +02:00
from settings import bp as settings_bp
from sr_session import sr_session
2022-05-22 16:52:01 +02:00
2022-06-07 00:28:11 +02:00
from config import CONFIG
2022-04-25 00:32:17 +02:00
def create_app(test_config=None):
# create and configure the app
app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping(
SECRET_KEY=CONFIG['SECRET_KEY']
)
2022-05-20 00:01:56 +02:00
2022-05-17 21:27:51 +02:00
@app.route('/')
2022-05-20 00:01:56 +02:00
@login_required
2022-05-17 21:27:51 +02:00
def index():
2022-05-20 00:01:56 +02:00
return 'redirecting' # meče skoz nazaj na login TODO
# Ce je napaka baze, naredi rollback
@app.errorhandler(500)
def internal_error(error):
session.rollback()
return render_template('500.html'), 500
2022-08-12 19:51:55 +02:00
@app.route('/deck', methods=["GET", "POST"])
2022-05-20 00:01:56 +02:00
def deck():
2022-08-16 10:44:13 +02:00
return sr_session()
2022-06-12 18:46:07 +02:00
@app.route("/share_button", methods=["GET", "POST"])
2022-06-14 02:27:05 +02:00
def share_button():
2022-06-12 18:46:07 +02:00
print("share!!!")
return redirect(url_for("deck"))
2022-05-22 16:52:01 +02:00
2022-07-07 18:14:53 +02:00
2022-05-20 00:01:56 +02:00
@app.route('/logout')
def logout():
session.pop("user_id", None)
return index()
2022-06-04 14:21:28 +02:00
@app.route('/match')
def match():
return "match"
2022-06-04 14:21:28 +02:00
2022-06-14 02:27:05 +02:00
2022-05-20 00:01:56 +02:00
#app.register_blueprint(bp) # ??
app.register_blueprint(auth_bp)
app.register_blueprint(deck_bp)
app.register_blueprint(menu_bp)
app.register_blueprint(upload_bp)
2023-04-08 23:39:36 +02:00
app.register_blueprint(import_link_bp)
2022-06-14 02:27:05 +02:00
app.register_blueprint(matches_bp)
2022-06-23 14:41:11 +02:00
app.register_blueprint(settings_bp)
2022-05-20 00:01:56 +02:00
app.add_url_rule('/', endpoint='index')
2022-05-13 18:23:15 +02:00
return app
2022-05-15 22:12:18 +02:00
app = create_app()
app.run(debug=True, host="0.0.0.0")