forked from expo/troggle
b66189bc9e
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8173 by julian @ 1/18/2009 12:45 AM
28 lines
687 B
Python
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" |