2022-08-07 17:46:04 +02:00
|
|
|
from flask import Flask, redirect, render_template, session, request, 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
|
2022-06-05 20:01:54 +02:00
|
|
|
from deck import bp as deck_bp
|
2022-06-04 21:55:34 +02:00
|
|
|
from menu import bp as menu_bp
|
2022-06-05 18:56:40 +02:00
|
|
|
from upload import bp as upload_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
|
2022-08-07 17:46:04 +02:00
|
|
|
from prob_session import prob_session
|
2022-05-22 16:52:01 +02:00
|
|
|
|
2022-06-07 00:28:11 +02:00
|
|
|
from config import CONFIG
|
2022-06-03 19:12:14 +02:00
|
|
|
|
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(
|
2022-06-14 14:03:29 +02:00
|
|
|
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
|
|
|
|
|
2022-06-14 14:03:29 +02:00
|
|
|
# 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-07 17:46:04 +02:00
|
|
|
return prob_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')
|
2022-06-04 21:55:34 +02:00
|
|
|
def match():
|
2022-06-05 18:56:40 +02:00
|
|
|
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)
|
2022-06-04 21:55:34 +02:00
|
|
|
app.register_blueprint(menu_bp)
|
2022-06-05 18:56:40 +02:00
|
|
|
app.register_blueprint(upload_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()
|
2022-06-14 14:03:29 +02:00
|
|
|
app.run(debug=True, host="0.0.0.0")
|