blob: 2c5b5a108f656e47e3d6bcbcbc8d6f8eefa5de80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import fileAbstraction
from django.http import HttpResponse, Http404
def listdir(request, path):
#try:
return HttpResponse(fileAbstraction.listdir(path), mimetype = "text/plain")
#except:
# raise Http404
def upload(request, path):
pass
def download(request, path):
#try:
return HttpResponse(fileAbstraction.readFile(path), mimetype=getMimeType(path.split(".")[-1]))
#except:
# raise Http404
def getMimeType(extension):
try:
return {"txt": "text/plain",
"html": "text/html",
}[extension]
except:
print "unknown file type"
return "text/plain"
|