Untitled
Rohit143
plain_text
2 years ago
1.2 kB
8
Indexable
from flask import Flask, render_template, request, redirect, url_for
app = Flask(__name__)
# Dummy user credentials for demonstration
users = {'username': 'password'}
@app.route('/')
def home():
return render_template('login.html')
@app.route('/login', methods=['POST'])
def login():
username = request.form.get('username')
password = request.form.get('password')
if username in users and users[username] == password:
return f'Welcome, {username}!'
else:
return 'Invalid login. Please try again.'
if __name__ == '__main__':
app.run(debug=True)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
</head>
<body>
<h2>Login</h2>
<form method="post" action="/login">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br>
<input type="submit" value="Login">
</form>
</body>
</html>
Editor is loading...
Leave a Comment