from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/login')
def login():
return render_template('login.html')
@app.route('/index')
def index():
username = request.args.get('username')
return f"主页!!!欢迎登录{username}"
app.run(debug=True)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="/index" method="get">
用户名: <input type="text" name="username" id="">
密码: <input type="password" name="pwd" id="">
<input type="submit" value="登录">
</form>
</body>
</html>