python - 如何从html中获取数据并将其作为对象,字典,在python中安全
问题描述
这是我的应用程序中的代码
@app.route('/registration', methods=["POST","GET"])
def createuser():
if request.method == "POST":
status =request.form("rstatus")
firstname = request.form("firstname")
dob = request.form("dob")
email = request.form("email")
number = request.form("number")
password = request.form("password")
lastname = request.form("lastname")
nickname = request.form("nickname")
if status == "Customer":
db = shelve.open("customer.db","c")
db[nickname] =[firstname,dob,email,number,password,lastname]
return render_template("Customer_Dashboard_Profile.HTML")
elif status == "Staff":
db = shelve.open("staff.db","c")
db[nickname] =[firstname,dob,email,number,password,lastname]
return render_template("Employee_Dashboard_Profile.HTML")
else:
print("ERROR")
这是我的html
<form action="/registration" class="form-signin" method="post">
<div class="form-label-group">
<select name="rstatus" id="rstatus" class="form-control">
<option value="Customer" selected>Customer</option>
<option value="Staff">Staff</option>
</select>
</div>
<div class="form-label-group">
<input type="text" id="inputfirstname" class="form-control" placeholder="First Name" name="firstname" required>
<label for="inputFirstname">First Name</label>
</div>
<div class="form-label-group">
<input type="date" id="inputDOB" class="form-control" placeholder="Date of Birth" name="dob"required>
<label for="inputDOB">Date of Birth</label>
</div>
<div class="form-label-group">
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" name="email" required autofocus>
<label for="inputEmail">Email address</label>
</div>
<div class="form-label-group">
<input type="number" id="inputphonenumber" class="form-control" placeholder="Phone Number" name="number" required min="80000000" max="99999999">
<label for="inputphonenumber">Phone Number</label>
</div>
<div class="form-label-group">
<input type="password" id="inputPassword" class="form-control" placeholder="Password" name="password" required>
<label for="inputPassword">Password</label>
</div>
<div class="form-label-group">
<input type="password" id="inputconfirmPassword" class="form-control" placeholder="Confirm Password" name="confirmpassword" required>
<label for="inputconfirmPassword">Confirm Password</label>
</div>
<div class="form-label-group">
<input type="text" id="inputlastname" class="form-control" placeholder="Last Name" name="lastname" required>
<label for="inputlastname">Last Name</label>
</div>
<div class="form-label-group">
<input type="text" id="inputnickname" class="form-control" placeholder="Nickname" name="nickname" required>
<label for="inputnickname">Nickname</label>
</div>
<button class="btn btn-lg btn-primary btn-block text-uppercase" type="submit">Register</button><br>
</form>
当我单击注册时,它会导致错误页面显示“未找到 404”。我觉得这个错误与来自 html 页面的请求或获取状态有关,但我不确定到底是什么问题
解决方案
推荐阅读
- java - Java vs C++(引用调用?)
- arm - 反向后的addr指令是什么
- sql - Postgresql - 如何识别 2 列组合的最新记录(内部示例)
- c# - 带小数的双重解析 C#
- python - django taggit-serializer 不在 rest 框架中创建标签
- azure-machine-learning-service - 从 AzureML 运行以编程方式获取 run_id
- python - Python 安装成功后无法导入 h2o
- swift - iOS Swift - 基于按钮框架的位置子视图(按钮位于垂直堆栈视图内)
- excel - VBA Excel Activex Frame控件包含选项按钮,当我离开设计模式时按钮消失
- android - 过滤芯片安卓