49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
import os
|
|
|
|
from flask import Flask, redirect, url_for
|
|
|
|
from . import about, admin, auth, db, game, question_sets, questions, utility
|
|
from .sockets import socketio
|
|
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
|
|
app.config.from_mapping(
|
|
SECRET_KEY="dev",
|
|
DATABASE=os.path.join(app.instance_path, "smarter.sqlite"),
|
|
BETA_VERSION=False,
|
|
|
|
# Flask-Mail is used for email, find more optional variables at
|
|
# https://flask-mail.readthedocs.io/en/latest/
|
|
MAIL_USERNAME=None,
|
|
MAIL_PASSWORD=None,
|
|
MAIL_DEFAULT_SENDER=None, # This must also be set, it is the only sender used
|
|
)
|
|
|
|
app.config.from_pyfile("config.py", silent=True)
|
|
|
|
# Create the instance folder if necessary
|
|
try:
|
|
os.makedirs(app.instance_path)
|
|
except OSError:
|
|
pass
|
|
|
|
# Register all blueprints
|
|
app.register_blueprint(auth.bp)
|
|
app.register_blueprint(questions.bp)
|
|
app.register_blueprint(about.bp)
|
|
app.register_blueprint(admin.bp)
|
|
app.register_blueprint(game.bp)
|
|
app.register_blueprint(question_sets.bp)
|
|
|
|
# Register app with some select modules
|
|
admin.init_app(app)
|
|
db.init_app(app)
|
|
|
|
utility.mail.init_app(app)
|
|
|
|
socketio.init_app(app)
|
|
|
|
|
|
@app.route("/")
|
|
def index():
|
|
return redirect(url_for("question_sets.browse"))
|