def main()

in app/__init__.py [0:0]


def main():
    app = quart.Quart(__name__)
    app.secret_key = secrets.token_hex()  # For session management

    # Static files (or index.html if requesting a dir listing)
    @app.route("/<path:path>")
    @app.route("/")
    async def static_files(path="index.html"):
        if path.endswith("/"):
            path += "index.html"
        return await quart.send_from_directory(STATIC_DIR, path)

    @app.before_serving
    async def load_endpoints():
        """Load all API end points. This is run before Quart starts serving requests"""
        async with app.app_context():
            from . import endpoints

    @app.after_serving
    async def shutdown():
        """Ensure a clean shutdown of the portal by stopping background tasks"""
        app.background_tasks.clear()  # Clear repo polling etc

    return app