Code

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

app.

py
from flask import Flask, render_template, request, redirect, url_for

app = Flask(__name__)

# Dummy biometric data (just for demonstration)


BIOMETRIC_DATA = {
'user1': 'biometric_data_1',
'user2': 'biometric_data_2'
}

@app.route('/')
def index():
return render_template('index.html')

@app.route('/login', methods=['GET', 'POST'])


def login():
if request.method == 'POST':
username = request.form['username']
biometric_input = request.form['biometric_input']
if username in BIOMETRIC_DATA and biometric_input ==
BIOMETRIC_DATA[username]:
# Authentication successful
return redirect(url_for('success'))
else:
# Authentication failed
return render_template('login.html', error='Authentication failed.
Please try again.')
return render_template('login.html')

@app.route('/success')
def success():
return render_template('success.html')

if __name__ == '__main__':
app.run(debug=True)
Templates/index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Biometric ATM Authentication</title>
</head>
<body>
<h1>Welcome to Biometric ATM Authentication</h1>
<p><a href="/login">Login</a></p>
</body>
</html>

templates/login.html:
<!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>
<center>
<h1>Login</h1>
{% if error %}
<p>{{ error }}</p>
{% endif %}
<form action="/login" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="biometric_input">Biometric Input:</label>
<input type="text" id="biometric_input" name="biometric_input"
required><br><br>
<button type="submit">Login</button>
</form>
</center>
</body>
</html>
templates/success.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Success</title>
</head>
<body>
<center>
<h1>Authentication Successful</h1>
<p>Welcome! You have successfully logged in.</p>
</center>
</body>
</html>

You might also like