Initialization
import os from flask import Flask from flask import ( redirect, url_for, session ) import secrets # From flask tutorial, # https://flask.palletsprojects.com/en/3.0.x/tutorial/factory/ from flask import Flask # https://flask-cors.readthedocs.io/en/latest/ #from flask_cors import CORS # Factory for creating the app object. Available throughout the app. def create_app(test_config=None): # create and configure the app app = Flask(__name__, instance_relative_config=True) app.config.from_mapping( SECRET_KEY=secrets.token_bytes(), DATABASE=os.path.join(app.instance_path, 'counter.sqlite') ) app.config.from_pyfile('config.py', silent=True) # ensure the instance folder exists try: os.makedirs(app.instance_path) except OSError: pass from . import db db.init_app(app) from . import gen app.register_blueprint(gen.bp) from . import register app.register_blueprint(register.bp) @app.route("/") def home(): return redirect(url_for("gen.init")) return app