用html搭建一个注册页面
from flask import Flask,request app = Flask(__name__) @app.route("/index/",methods = ['get','post']) def index(): print(request.form) print(request.files) # file1 = request.files.get("myfile") # file1.save('fil') return 'OK' app.run()
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>用户注册</title> </head> <body> <form action="http://127.0.0.1:5000/index/" method="post" enctype="multipart/form-data"> <p><label>username:<input type="text" name="username" placeholder="请输入用户名"></label></p> <p><label>password:<input type="password" name="password" placeholder="请输入密码"></></p> <p> <label>re_pwd:<input type="password" name="re_pwd" placeholder="请确认密码"></label> </p> <p> <label for=""> <input type="radio" name="gender">male <input type="radio" name="gender">female <input type="radio" name="gender">other </label> </p> <p> <input type="submit" value="注册"> </p> </form> </body> </html>