MyApp/
├── app.py
└── templates/
├── register.html
└── success.html
1. app.py
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def index():
return '<h2>Welcome to the Home Page</h2><a href="/register">Go to
Registration</a>'
@app.route('/register', methods=['GET', 'POST'])
def register():
if request.method == 'POST':
name = request.form.get('name')
email = request.form.get('email')
return render_template('success.html', name=name, email=email)
return render_template('register.html')
if __name__ == '__main__':
app.run(debug=True)
2. templates/register.html
<!DOCTYPE html>
<html>
<head>
<title>Register</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f2f2f2;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.form-box {
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.2);
width: 300px;
}
input[type="text"], input[type="email"], input[type="password"] {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px;
width: 100%;
border: none;
border-radius: 5px;
margin-top: 10px;
cursor: pointer;
}
h2 {
text-align: center;
}
</style>
</head>
<body>
<div class="form-box">
<h2>Register</h2>
<form method="POST">
<input type="text" name="name" placeholder="Your Name" required>
<input type="email" name="email" placeholder="Email Address" required>
<input type="password" name="password" placeholder="Password" required>
<input type="submit" value="Register">
</form>
</div>
</body>
</html>
3. templates/success.html
<!DOCTYPE html>
<html>
<head>
<title>Registration Success</title>
<style>
body {
font-family: Arial, sans-serif;
background: #e6ffee;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.success-box {
background: white;
padding: 30px;
border-radius: 10px;
text-align: center;
box-shadow: 0px 0px 10px rgba(0,0,0,0.2);
}
h2 {
color: green;
}
</style>
</head>
<body>
<div class="success-box">
<h2>Registration Successful!</h2>
<p><strong>Name:</strong> {{ name }}</p>
<p><strong>Email:</strong> {{ email }}</p>
<a href="/register">Register Another User</a>
</div>
</body>
</html>