【发布时间】:2021-03-20 07:41:19
【问题描述】:
我正在我的 ecom 网站上为供应商制作注册表单,并且在执行发布请求时遇到了错误的请求错误。我试图找出导致此错误的原因,但一切似乎都很好。我使用了一个类似的模板,它工作正常,但我不知道这个有什么问题。看看我的代码,请帮我找出问题所在。
HTML 代码:
<div class="col">
<form action="{{ url_for('Vendor_registration') }}" method="post" style="padding-top:1%;">
<div class="form-group">
<label for="first">First Name:</label>
<input type="text" name="first_name" class="form-control" placeholder="For eg : Andrew" id="first" maxlength="15">
</div>
<div class="form-group">
<label for="middle">Middle Name:</label>
<input type="text" name="middle_name" class="form-control" placeholder="For eg : Jason" id="middle" maxlength="15">
</div>
<div class="form-group">
<label for="last">Last Name:</label>
<input type="text" name="last_name" class="form-control" placeholder="For eg : Sebastian" id="last" maxlength="15">
</div>
<div class="form-group">
<label for="contact">Contact Number:</label>
<input type="text" name="contact_no" class="form-control" placeholder="For eg : 0123456789" id="contact" maxlength="10">
</div>
<div class="form-group">
<label for="email">Email address:</label>
<input type="email" name="email" class="form-control" placeholder="For eg : abc@abc.com" id="email" maxlength="30">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" name="password" class="form-control" placeholder="********" id="pwd" maxlength="15">
</div>
<div class="form-group">
<label for="shop">Shop Name:</label>
<input type="text" name="shop_name" class="form-control" placeholder="For eg : abc store" id="shop" maxlength="15">
</div>
<div class="form-group">
<label for="certificate">Shop Certificate:</label>
<input type="file" name="image" class="form-control-file border" id="certificate">
</div>
<div class="form-group">
<label for="account">Bank Account number:</label>
<input type="text" name="account_no" class="form-control" id="account" maxlength="20">
</div>
<div class="form-group">
<label for="upi">UPI ID:</label>
<input type="text" name="upi_id" class="form-control" id="upi" maxlength="15">
</div>
<button type="submit" class="btn btn-success btn-block">Submit</button>
</form>
</div>
Python 代码:
@app.route("/vendor_register", methods=["GET","POST"])
def Vendor_registration():
email=str(request.form.get("email"))
first_name=str(request.form.get("first_name"))
middle_name=str(request.form.get("middle_name"))
last_name=str(request.form.get("last_name"))
shop_name=str(request.form.get("shop_name"))
phone_no=str(request.form.get("contact_no"))
password=str(request.form.get("password"))
account_no=str(request.form.get("account_no"))
upi_id=str(request.form.get("upi_id"))
shop_certificate=" "
file=request.files["image"]
return "done"
日志:
└─$ flask run
* Serving Flask app "application.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [20/Mar/2021 03:13:46] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [20/Mar/2021 03:13:48] "POST /vendor_registration HTTP/1.1" 200 -
127.0.0.1 - - [20/Mar/2021 03:13:58] "POST /vendor_register HTTP/1.1" 400 -
^C
【问题讨论】:
-
你的服务器有日志吗?另见:Debugging Application Errors
-
哦,是的,我现在已经提到了它们。看看吧。
标签: html python-3.x flask