Files
gander/web_server/blueprints/__init__.py
Chris-1010 6586506c97 MAJOR Fix: Resolved API Request Delays;
Feat: Added a dev test account to users for expedited login;
Refactor: Improve socket connection handling and add logging for API request duration & update to ListRow key generation for improved uniqueness;
Feat: Made it so streams with no set thumbnail use their category's thumbnail;
Minor Fix: Corrections to db recommendation methods;
2025-01-30 03:53:33 +00:00

58 lines
1.7 KiB
Python

from flask import Flask
from flask_session import Session
from flask_cors import CORS
from blueprints.utils import logged_in_user, record_time
from blueprints.errorhandlers import register_error_handlers
# from flask_wtf.csrf import CSRFProtect, generate_csrf
from blueprints.authentication import auth_bp
from blueprints.stripe import stripe_bp
from blueprints.user import user_bp
from blueprints.streams import stream_bp
from blueprints.chat import chat_bp
from blueprints.socket import socketio
from os import getenv
# csrf = CSRFProtect()
def create_app():
"""
Set up the flask app by registering all the blueprints and configuring
the settings. Also create a CSRF token to prevent Cross-site Request Forgery.
And setup web sockets to be used throughout the project.
"""
app = Flask(__name__)
app.config["SECRET_KEY"] = getenv("FLASK_SECRET_KEY")
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
#! ↓↓↓ For development purposes only - Allow cross-origin requests for the frontend
CORS(app, supports_credentials=True)
# csrf.init_app(app)
socketio.init_app(app)
Session(app)
app.before_request(logged_in_user)
app.after_request(record_time)
# adds in error handlers
register_error_handlers(app)
# @app.route('/csrf-token')
# def get_csrf_token():
# return jsonify({'csrf_token': generate_csrf()}), 200
with app.app_context():
# Registering Blueprints
app.register_blueprint(auth_bp)
app.register_blueprint(stripe_bp)
app.register_blueprint(user_bp)
app.register_blueprint(stream_bp)
app.register_blueprint(chat_bp)
socketio.init_app(app)
return app