From 5cba2a97e9f5da934007c746b07052e6208ed4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 21 May 2024 16:45:50 +0200 Subject: [PATCH] new: Optionally make the capture page the default landing page --- config/generic.json.sample | 2 ++ website/web/__init__.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config/generic.json.sample b/config/generic.json.sample index 97bfaf22..6ac94025 100644 --- a/config/generic.json.sample +++ b/config/generic.json.sample @@ -7,6 +7,7 @@ "website_listen_port": 5100, "systemd_service_name": "lookyloo", "default_public": true, + "index_is_capture": false, "users": {}, "time_delta_on_index": { "weeks": 1, @@ -90,6 +91,7 @@ "website_listen_port": "Port Flask will listen on.", "systemd_service_name": "(Optional) Name of the systemd service if your project has one.", "default_public": "If true, the capture is public and will be visible on the index page by default (can be unticked on the capture page).", + "index_is_capture": "If true, the capture page is the default landing page (faster for big instances).", "users": "It is some kind of an admin accounts. Format: {username: password}", "time_delta_on_index": "Time interval of the capture displayed on the index", "async_capture_processes": "Number of async_capture processes to start. This should not be higher than the number of splash instances you have running. A very high number will use *a lot* of ram.", diff --git a/website/web/__init__.py b/website/web/__init__.py index a5423809..6eef395a 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -78,6 +78,15 @@ login_manager.init_app(app) # User agents manager user_agents = UserAgents() +if get_config('generic', 'index_is_capture'): + @app.route('/', methods=['GET']) + def landing_page() -> WerkzeugResponse: + return redirect(url_for('capture_web')) +else: + @app.route('/', methods=['GET']) + def landing_page() -> WerkzeugResponse: + return redirect(url_for('index')) + @login_manager.user_loader # type: ignore[misc] def user_loader(username: str) -> User | None: @@ -1317,7 +1326,7 @@ def get_index_params(request: Request) -> tuple[bool, str]: # ##### Index level methods ##### -@app.route('/', methods=['GET']) +@app.route('/index', methods=['GET']) def index() -> str: if request.method == 'HEAD': # Just returns ack if the webserver is running