Added the html forms code

This commit is contained in:
Mohammad Rameen 2025-09-01 03:49:16 +05:30
parent f63f2f5468
commit 7b3dc06ad0
2 changed files with 14 additions and 7 deletions

View File

@ -1,4 +1,4 @@
from flask import Flask, render_template from flask import Flask, render_template, request
app = Flask(__name__) app = Flask(__name__)
@ -6,5 +6,11 @@ app = Flask(__name__)
def home(): def home():
return render_template("index.html") return render_template("index.html")
@app.route('/login', methods=["POST"])
def receive_data():
name = request.form["username"]
password = request.form["password"]
return f"<h1>Name: {name}, Password: {password}</h1>"
if __name__ == "__main__": if __name__ == "__main__":
app.run(debug=True) app.run(debug=True)

View File

@ -6,11 +6,12 @@
<title>Title</title> <title>Title</title>
</head> </head>
<body> <body>
<form action="/login" method="post">
<label>Name</label> <label>Name</label>
<input type="text" placeholder="name"> <input type="text" placeholder="name" name="username">
<label>Password</label> <label>Password</label>
<input type="text" placeholder="password"> <input type="text" placeholder="password" name="password">
<button type="text">Ok</button> <button type="text">Ok</button>
</form>
</body> </body>
</html> </html>