【发布时间】:2013-07-23 14:32:32
【问题描述】:
我想列出目录和子目录中的文件。我使用this answer 来获得列表,但这些项目是不可点击的,所以我想在文件名称和它们的位置之间添加一个链接。我尝试用这样的东西修改模板:
<!doctype html>
<title>Path: {{ tree.name }}</title>
<h1>{{ tree.name }}</h1>
<ul>
{%- for item in tree.children recursive %}
<li><a href="{{ item.name }}">{{ item.name }}</a>
{%- if item.children -%}
<ul><a href="{{ loop(item.children) }}">{{ loop(item.children) }}</a></ul>
{%- endif %}</li>
{%- endfor %}
</ul>
但是不行,链接不好。当我想要一个指向 http://192.168.0.70:5000/static/repertory/subrepertory/file 的链接时,我有一个指向 http://192.168.0.70:5000/file 的链接,它会导致 404。有人可以帮助我吗?
【问题讨论】: