troggle-unchained/expo/view_surveys.py
2009-05-13 05:34:52 +01:00

28 lines
687 B
Python

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"