- 文件框架
- app.py文件
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def index():
return register()
@app.route('/register', methods=["GET"])
def register():
return render_template("register.html")
@app.route('/get/reg', methods=["GET"])
def get_register():
print(request.args)
return "注册成功"
@app.route('/post/reg', methods=["POST"])
def post_register():
print(request.form)
return "注册成功"
if __name__ == '__main__':
app.run()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>用户注册</h1>
<form method="get" action="/get/reg"> <!--可以写成post-->
用户名:<input type="text" name="user">
密码 :<input type="password" name="pwd">
<input type="submit" value="submit按钮">
</form>
</body>
</html>