浏览代码

support file download

https
jakobsn 6 年前
父节点
当前提交
61cf2b8f3e
共有 2 个文件被更改,包括 5 次插入2 次删除
  1. +3
    -0
      src/app/templates/project.html
  2. +2
    -2
      src/app/views/project.py

+ 3
- 0
src/app/templates/project.html 查看文件

@@ -22,6 +22,9 @@ $def with (nav, project, tasks)
$for task in tasks: $for task in tasks:
<li id="$task[0]">$task <li id="$task[0]">$task
<br> <br>
$for filename in get_task_files(task[0]):
<a href="$filename[0]" download>$filename[0].split("/")[-1]</a>
<br>
<form method="POST" enctype="multipart/form-data" action=""> <form method="POST" enctype="multipart/form-data" action="">
<input type="file" name="myfile" /> <input type="file" name="myfile" />
<br/> <br/>


+ 2
- 2
src/app/views/project.py 查看文件

@@ -30,7 +30,7 @@ class Project:
else: else:
project = [[]] project = [[]]
tasks = [[]] tasks = [[]]
render = web.template.render('templates/', globals={'get_task_files':models.project.get_task_files})
return render.project(nav, project[0], tasks) return render.project(nav, project[0], tasks)


def POST(self): def POST(self):
@@ -59,7 +59,7 @@ class Project:
sleep(0.5) sleep(0.5)
open(path + '/' + fn, 'wb').write(fileitem.file.read()) open(path + '/' + fn, 'wb').write(fileitem.file.read())
message = 'The file "' + fn + '" was uploaded successfully' message = 'The file "' + fn + '" was uploaded successfully'
models.project.set_task_file(data.taskid, (path + "/" + fn))
else: else:
message = 'No file was uploaded' message = 'No file was uploaded'


正在加载...
取消
保存