Skip to content

Instantly share code, notes, and snippets.

@thenewguy
thenewguy / middleware.py
Created January 17, 2016 22:54
static serve middleware based off whitenoise
import mimetypes
import time
from os.path import splitext
from django.contrib.staticfiles.storage import staticfiles_storage
from django.http import HttpResponse, FileResponse, HttpResponseNotAllowed, Http404
from django.core.exceptions import SuspiciousFileOperation
from django.conf import settings
from django.utils.six import text_type
from django.utils.http import http_date