From 9f3035c8226f28304d5aae2ee610b231154d1194 Mon Sep 17 00:00:00 2001 From: Kumaresan Date: Fri, 7 Aug 2026 15:15:28 +0530 Subject: [PATCH] 'flask' --- app.py | 102 ++++++++++++++++++++++++++++++++++++++++++ templates/index.html | 91 +++++++++++++++++++++++++++++++++++++ templates/result.html | 46 +++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 app.py create mode 100644 templates/index.html create mode 100644 templates/result.html diff --git a/app.py b/app.py new file mode 100644 index 0000000..cbf7ac2 --- /dev/null +++ b/app.py @@ -0,0 +1,102 @@ +from flask import Flask, render_template, request +from datetime import datetime + +app = Flask(__name__) + +logs = [] + +@app.route("/") +def home(): + return render_template("index.html") + + +@app.route("/login", methods=["POST"]) +def login(): + username = request.form.get("username", "") + password = request.form.get("password", "") + + logs.append({ + "time": datetime.now().strftime("%H:%M:%S"), + "type": "Login", + "username": username, + "password": password + }) + + return render_template( + "result.html", + title="Login", + message="Demo login received. (No authentication performed.)", + data={"Username": username} + ) + + +@app.route("/search") +def search(): + q = request.args.get("q", "") + + logs.append({ + "time": datetime.now().strftime("%H:%M:%S"), + "type": "Search", + "query": q + }) + + return render_template( + "result.html", + title="Search", + message="Search request received.", + data={"Query": q} + ) + + +@app.route("/contact", methods=["POST"]) +def contact(): + name = request.form.get("name", "") + email = request.form.get("email", "") + message = request.form.get("message", "") + + logs.append({ + "time": datetime.now().strftime("%H:%M:%S"), + "type": "Contact", + "name": name, + "email": email + }) + + return render_template( + "result.html", + title="Contact", + message="Contact form submitted.", + data={ + "Name": name, + "Email": email, + "Message": message + } + ) + + +@app.route("/logs") +def view_logs(): + html = """ +

Application Logs

+ + + + + + + """ + + for log in reversed(logs): + html += f""" + + + + + + """ + + html += "
TimeTypeDetails
{log['time']}{log['type']}{log}
" + return html + + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=5000, debug=True) \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..b3846f0 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,91 @@ + + + + SafeLine Demo App + + + + + + +
+ +
+Educational Demo
+This application is running behind SafeLine WAF. +
+ +

SafeLine Demo Application

+ +
+ +

Login

+ +
+ + + + + + + +
+ +
+ +

Search

+ +
+ + + + + +
+ +
+ +

Contact

+ +
+ + + + + + + + + +
+ +
+ + +View Logs + + +
+ + + \ No newline at end of file diff --git a/templates/result.html b/templates/result.html new file mode 100644 index 0000000..3bfdb2b --- /dev/null +++ b/templates/result.html @@ -0,0 +1,46 @@ + + + + + + + + + + + +
+ +

{{ title }}

+ +
+{{ message }} +
+ + + +
+ + + +Back + + + +
+ + + + \ No newline at end of file