如何给出烧瓶删除方法的超链接。这是代码HTML代码。我已经用 HTML 编写了超链接。那么,如何在烧瓶路由中传递 url。我正在使用 Flask 框架,并且正在尝试从数据库中删除一个条目。下面的代码给出了这个错误:“请求的 URL 不允许该方法。”
{% extends "base.html" %}
{% block head %}
{{super()}}
{% endblock %}
{% block navbar %}
{{super()}}
{% endblock %}
{% block content %}
<div class="row">
<ol class="breadcrumb">
<li><a href="#">
<em class="fa fa-home"></em> </a></li>
<li class="active">Users>View/Edit</li>
</ol>
</div><!--/.row-->
<div class="row">
<div class="col-md-12">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>
Name
</th>
<th>
Email
</th>
<th>
Address
</th>
<th>
Aadharimage
</th>
<th>
Password
</th>
<th>
Locations
</th>
<th>
Dateofsub
</th>
<th>
Lastlogin
</th>
<th>
Control
</th>
<th>
Delete
</th>
</tr>
</thead>
{% for values in endusers %}
<tr>
<td>{{values.name}}</td>
<td>{{values.email}}</td>
<td>{{values.address}}</td>
<td> <img src="{{url_for('static', filename='assets/images /{{values.aadharimage}}')}}" width="24" height="24">{{values.aadharimage}}</td>`
<!-- <td><img src=" {{url_for('static', filename=' /assets/images/tms.png')}}" width="25" height="50"/></td>-->
<td>********</td>
<td>{{values.locations}}</td>
<td>{{values.dateofsub}}</td>
<td>{{values.lastlogin}}</td>
<td><a href="/Control/resetuserpass/{{values.id}}" class="btn btninfo">Reset Password</a></td>
<td><a href="{{ url_for('delete_user', postID=values.id) }}" class="btn btn-danger">Delete</a></td>
</tr>
{% endfor %}
</table>
<a href = "/page/new user"> <em class="fa fa-xl fa-plus-circle color-blue"></em> </a>
</div>
</div>
{% endblock %}
Here is the flask code this is correct ? I am trying for 2 days please solve this problem. While running thus code it showing 404 and 405 method.
@app.route('/delete/<int:postID>', methods=['DELETE'])
def delete_user(postID):
if not session.get('logged_in'):
abort(401)
sqlsession.execute('delete from values WHERE id = ?', [postID])
flash('Entry was deleted')
return redirect(url_for('pageedituser'))