-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestserver.py
More file actions
38 lines (34 loc) · 1.06 KB
/
testserver.py
File metadata and controls
38 lines (34 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#using flask username = admin & password = admin ; port 5000
#test server for testing brute_force.py
from flask import Flask, request, render_template_string, redirect
app = Flask(__name__)
HTML = """
<!DOCTYPE html>
<html>
<head><title>Login</title></head>
<body>
<h2>Login Page</h2>
<form method="POST" action="/login">
<input type="text" name="username" placeholder="Username" /><br><br>
<input type="password" name="password" placeholder="Password" /><br><br>
<input type="submit" value="Login" />
</form>
{% if error %}
<p style="color:red;">{{ error }}</p>
{% endif %}
</body>
</html>
"""
@app.route("/login", methods=["GET", "POST"])
def login():
error = None
if request.method == "POST":
user = request.form.get("username")
passwd = request.form.get("password")
if user == "admin" and passwd == "admin":
return "Welcome admin!"
else:
error = "Invalid credentials"
return render_template_string(HTML, error=error)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)