删除我的代码中未被命中的路由

时间:2017-04-18 07:23:19

标签: python html url flask

images.html

.nav-pills>li.active {
    border-radius: 0;
}

website.py

<body>
{% if msg %}   <h1>{{ msg }}!</h1>  {% endif %}

 <div class="container">
   <h1>Here you can upload a file</h1>
   <form id="upload_form" action="/upload" method="POST" enctype="multipart/form-data">
      <input type="file" name="file" accept="uploaded_files/*" multiple>
      <input type="submit" name="upload" value="Upload">
   </form>
   <hr>
  <!--- <h1>Here you can download a file</h1>
   <form id="download_form" action="/download" method="POST">
     File Name: <input type="text" name="filename" placeholder="Enter file name"><br><br>

     <input type="submit" name="download" value="download">
   </form>
   <hr>
   <h1>Here you can delete a file</h1>
   <form id="delete_form" action="/delete" method="POST">
     File Name: <input type="text" name="filename" placeholder="Enter file name"><br><br>
     <input type="submit" name="delete" value="delete">
   </form>
   <hr>--->
   <h1>Here you can List,Download and delete all the files</h1>
   {% if list_names %}
   {% for item in list_names %}
       <!--- <a href="/download/{{ item }}">{{ item }}</a>--->

    <img src="{{item}}" height="400px"/>
     <a href="/delete{{item}}">delete</a>
    {% endfor %}
    {% endif %}

   <form id="list_form" action="/list_files" method="POST">
     <input type="submit" name="list" value="list">
   </form>
   <hr>
  </div>
 </body>

以上是我的代码。在我的HTML中,我已经包含要删除的锚标记。 item将给出图像的路径。所以当我点击锚点时,它正在搜索路线为&#39; /detete/static/Uploads/14199543_1107156822698054_3500700356588134783_n.jpg'

在我的python代码中,我添加了路由@ app.route(&#39; / delete&#39;)。我期待文件名将从html捕获路径。但我想这不起作用。我如何从html获取项目,这是图像的路径到python代码,以便我可以在where子句中编写包含它的删除查询。或者有人可以解释如何编写删除函数,当我单击锚标记时删除图像。

我的代码很乱。但列表和登录工作正常。有关删除的任何帮助表示赞赏。提前致谢

0 个答案:

没有答案