This commit is contained in:
2026-08-07 15:15:28 +05:30
commit 9f3035c822
3 changed files with 239 additions and 0 deletions
+102
View File
@@ -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 = """
<h2>Application Logs</h2>
<table border=1 cellpadding=8>
<tr>
<th>Time</th>
<th>Type</th>
<th>Details</th>
</tr>
"""
for log in reversed(logs):
html += f"""
<tr>
<td>{log['time']}</td>
<td>{log['type']}</td>
<td>{log}</td>
</tr>
"""
html += "</table>"
return html
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)
+91
View File
@@ -0,0 +1,91 @@
<!DOCTYPE html>
<html>
<head>
<title>SafeLine Demo App</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container mt-5">
<div class="alert alert-warning">
<b>Educational Demo</b><br>
This application is running behind SafeLine WAF.
</div>
<h2>SafeLine Demo Application</h2>
<hr>
<h4>Login</h4>
<form action="/login" method="POST">
<input class="form-control mb-2"
name="username"
placeholder="Username">
<input class="form-control mb-2"
type="password"
name="password"
placeholder="Password">
<button class="btn btn-primary">
Login
</button>
</form>
<hr>
<h4>Search</h4>
<form action="/search">
<input class="form-control mb-2"
name="q"
placeholder="Search">
<button class="btn btn-success">
Search
</button>
</form>
<hr>
<h4>Contact</h4>
<form action="/contact" method="POST">
<input class="form-control mb-2"
name="name"
placeholder="Name">
<input class="form-control mb-2"
name="email"
placeholder="Email">
<textarea
class="form-control mb-2"
name="message"
placeholder="Message"></textarea>
<button class="btn btn-dark">
Send
</button>
</form>
<br>
<a href="/logs" class="btn btn-outline-secondary">
View Logs
</a>
</div>
</body>
</html>
+46
View File
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container mt-5">
<h2>{{ title }}</h2>
<div class="alert alert-success">
{{ message }}
</div>
<ul class="list-group">
{% for k,v in data.items() %}
<li class="list-group-item">
<b>{{k}}</b> : {{v}}
</li>
{% endfor %}
</ul>
<br>
<a href="/" class="btn btn-primary">
Back
</a>
</div>
</body>
</html>