from werkzeug.middleware.proxy_fix import ProxyFix from mirrormanager2.app import create_app from flask_session import Session from cachelib.file import FileSystemCache import os password = os.environ.get('MM2_DATABASE_PASSWORD') if password: user = os.environ.get('DB_USER') host = os.environ.get('DB_HOST') port = os.environ.get('DB_PORT') name = os.environ.get('DB_NAME') os.environ["MM2_SQLALCHEMY_DATABASE_URI"] = f"postgresql://{user}:{password}@{host}:{port}/{name}" application = create_app() application.debug = os.environ.get("MM2_DEBUG", False) application.config['SESSION_TYPE'] = "cachelib" application.config['SESSION_CACHELIB'] = FileSystemCache(cache_dir='/tmp/sessions', threshold=500) Session(application) application.wsgi_app = ProxyFix(application.wsgi_app, x_proto=1, x_host=1)