create a login page with the username test and the password 123 in python

Here's a simple code snippet that creates a login page in Python using Flask framework with hardcoded username and password:

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

app = Flask(__name__)

@app.route("/", methods=["GET", "POST"])
def login():
    if request.method == "POST":
        # Get form data
        username = request.form["username"]
        password = request.form["password"]

        # Check username and password
        if username == "test" and password == "123":
            return redirect(url_for("home"))
        else:
            return render_template("login.html", error=True)

    return render_template("login.html", error=False)

@app.route("/home")
def home():
    return "<h1>Welcome to your account!</h1>"

if __name__ == "__main__":
    app.run(debug=True)
691 chars
26 lines

Note that this is for demonstration purposes only and should not be used in a real-world scenario, as hardcoded credentials are not secure. In a real-world scenario, you would use a database to store and verify user credentials, and implement encryption to protect the password.

gistlibby LogSnag