From cafa9c150229d2311045743f64cd49f0c5766a78 Mon Sep 17 00:00:00 2001 From: Adrian Maraj Date: Tue, 30 Apr 2024 11:54:24 +0200 Subject: [PATCH] new simple capture --- website/web/__init__.py | 24 ++++ website/web/templates/index.html | 5 + website/web/templates/simple_capture.html | 127 ++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 website/web/templates/simple_capture.html diff --git a/website/web/__init__.py b/website/web/__init__.py index 0bd8158..59d4a28 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -1632,6 +1632,30 @@ def capture_web() -> str | Response | WerkzeugResponse: # render template return _prepare_capture_template(user_ua=request.headers.get('User-Agent')) +@app.route('/simple_capture', methods=['GET', 'POST']) +def simple_capture() -> str | Response | WerkzeugResponse: + if flask_login.current_user.is_authenticated: + user = flask_login.current_user.get_id() + else: + user = src_request_ip(request) + + if request.method == 'POST': + if not (request.form.get('url') or request.form.get('urls')): + flash('Invalid submission: please submit at least a URL.', 'error') + return render_template('simple_capture.html') + capture_query: CaptureSettings = {} + capture_query['url'] = request.form['url'] + + perma_uuid = lookyloo.enqueue_capture(capture_query, source='web', user=user, + authenticated=flask_login.current_user.is_authenticated) + if perma_uuid: + flash('Recording is in progress and is reported automatically.', 'success') + time.sleep(2) + return redirect(url_for('simple_capture')) + + # render template + return render_template('simple_capture.html') + @app.route('/cookies/', methods=['GET']) def cookies_name_detail(cookie_name: str) -> str: diff --git a/website/web/templates/index.html b/website/web/templates/index.html index a9ee30f..9bf88f0 100644 --- a/website/web/templates/index.html +++ b/website/web/templates/index.html @@ -83,6 +83,11 @@ $(document).ready(function () { + {% if current_user.is_authenticated %} + + + + {% endif %}

{{ render_messages(container=True, dismissible=True) }} diff --git a/website/web/templates/simple_capture.html b/website/web/templates/simple_capture.html new file mode 100644 index 0000000..3ac7c60 --- /dev/null +++ b/website/web/templates/simple_capture.html @@ -0,0 +1,127 @@ +{% extends "main.html" %} +{% from 'bootstrap5/utils.html' import render_messages %} +{% block title %}Capture{% endblock %} + +{% block card %} + + + + + + +{% endblock %} + +{% block content %} +
+
+ + Lookyloo + +
+ {{ render_messages(container=True, dismissible=True) }} +
+
+
+
+ + +
+ + +
+
+
+ + + + +
+ + + +
+ + {% if default_public %} + By default, the capture is private. If you do not want that, untick the box at the top of the form. + {% else %} + By default, the capture is private (not visible on the index page). If you want it to be public tick the box at the top of the form. + {% endif %} + +
+
+ +
+
+
+{% endblock %} + +{% block scripts %} + {{ super() }} + + + + + +{% endblock %}