1
如何動態生成使用燒瓶的文件鏈接?這裏是我的示例代碼,但當我點擊鏈接時它不工作。目錄中的所有文件都是文本文件,因此瀏覽器可以在不下載任何內容的情況下打開它們。燒瓶,動態生成文件鏈接
{% for x, y in links %}
<tr>
<td><a href="{{y}}">{{x}}</a></td>
<td><a href="{{y}}">{{y}}</a></td>
</tr>
{% endfor %}
path = 'path/directory'
if request.method == 'GET':
# a is the date last modified, b is the file path
link = [(a, b) for a, b in get_files_sorted(path)]
return render_template('file_structure.html', links=link)
if request.method == 'POST':
#open the text file that was clicked on