forked from expo/troggle
more mimetypes for flatfiles
This commit is contained in:
parent
a0f504d1e2
commit
87b30741fc
@ -66,8 +66,9 @@ def flatpage(request, path):
|
|||||||
return render(request, 'pagenotfound.html', {'path': path})
|
return render(request, 'pagenotfound.html', {'path': path})
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
#print(" - FLATPAGES the file: {} ...".format(path))
|
#print(" - FLATPAGES the file: '{}' ...".format(path))
|
||||||
if path.startswith("site_media"):
|
#print(" - FLATPAGES MEDIA_ROOT: '{}' ...".format(settings.MEDIA_ROOT))
|
||||||
|
if path.startswith('site_media'):
|
||||||
#print(" - MEDIA_ROOT: {} ...".format(settings.MEDIA_ROOT))
|
#print(" - MEDIA_ROOT: {} ...".format(settings.MEDIA_ROOT))
|
||||||
path = path.replace("site_media", settings.MEDIA_ROOT)
|
path = path.replace("site_media", settings.MEDIA_ROOT)
|
||||||
filetobeopened = os.path.normpath(path)
|
filetobeopened = os.path.normpath(path)
|
||||||
@ -76,7 +77,9 @@ def flatpage(request, path):
|
|||||||
path = path.replace("static", settings.MEDIA_ROOT)
|
path = path.replace("static", settings.MEDIA_ROOT)
|
||||||
filetobeopened = os.path.normpath(path)
|
filetobeopened = os.path.normpath(path)
|
||||||
else:
|
else:
|
||||||
|
#print(" - NO _ROOT: {} ...".format(settings.EXPOWEB))
|
||||||
filetobeopened = os.path.normpath(settings.EXPOWEB + path)
|
filetobeopened = os.path.normpath(settings.EXPOWEB + path)
|
||||||
|
|
||||||
#print(" - FLATPAGES full path : {} ...".format(filetobeopened))
|
#print(" - FLATPAGES full path : {} ...".format(filetobeopened))
|
||||||
o = open(filetobeopened, "rb")
|
o = open(filetobeopened, "rb")
|
||||||
#print(" - FLATPAGES full path no error: {} ...".format(filetobeopened))
|
#print(" - FLATPAGES full path no error: {} ...".format(filetobeopened))
|
||||||
@ -121,13 +124,16 @@ def flatpage(request, path):
|
|||||||
|
|
||||||
def getmimetype(path):
|
def getmimetype(path):
|
||||||
if path.lower().endswith(".css"): return "text/css"
|
if path.lower().endswith(".css"): return "text/css"
|
||||||
|
if path.lower().endswith(".txt"): return "text/css"
|
||||||
if path.lower().endswith(".js"): return "application/javascript"
|
if path.lower().endswith(".js"): return "application/javascript"
|
||||||
|
if path.lower().endswith(".json"): return "application/javascript"
|
||||||
if path.lower().endswith(".png"): return "image/png"
|
if path.lower().endswith(".png"): return "image/png"
|
||||||
if path.lower().endswith(".tif"): return "image/tif"
|
if path.lower().endswith(".tif"): return "image/tif"
|
||||||
if path.lower().endswith(".gif"): return "image/gif"
|
if path.lower().endswith(".gif"): return "image/gif"
|
||||||
if path.lower().endswith(".jpeg"): return "image/jpeg"
|
if path.lower().endswith(".jpeg"): return "image/jpeg"
|
||||||
if path.lower().endswith(".jpg"): return "image/jpeg"
|
if path.lower().endswith(".jpg"): return "image/jpeg"
|
||||||
if path.lower().endswith("svg"): return "image/svg+xml"
|
if path.lower().endswith("svg"): return "image/svg+xml"
|
||||||
|
if path.lower().endswith("xml"): return "image/xml"
|
||||||
if path.lower().endswith(".pdf"): return "application/pdf"
|
if path.lower().endswith(".pdf"): return "application/pdf"
|
||||||
if path.lower().endswith(".ps"): return "application/postscript"
|
if path.lower().endswith(".ps"): return "application/postscript"
|
||||||
if path.lower().endswith(".svx"): return "application/x-survex-svx"
|
if path.lower().endswith(".svx"): return "application/x-survex-svx"
|
||||||
|
Loading…
Reference in New Issue
Block a user