In HTML
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="login-container">
<h2>Login</h2>
<form action="login.py" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="Login">
</form>
</div>
</body>
</html>
CSS:
.login-container {
max-width: 300px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #f4f4f4;
}
h2 {
text-align: center;
}
label {
display: block;
margin-bottom: 10px;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 5px;
margin-bottom: 10px;
}
input[type="submit"] {
width: 100%;
padding: 10px;
background-color: #4caf50;
border: none;
color: white;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
Phyton:
#!/usr/bin/env python
import cgi
print("Content-Type: text/html\n")
form = cgi.FieldStorage()
username = form.getvalue("username")
password = form.getvalue("password")
if username == "your_username" and password == "your_password":
print("<h1>Login Successful</h1>")
else:
print("<h1>Login Failed</h1>")