import mimetypes

from django.http import HttpResponse, HttpResponseNotModified, Http404
from django.contrib.staticfiles.views import serve as staticfiles_serve
from django.views.static import was_modified_since, http_date

from staticassets import finder, settings


def serve(request, path, **kwargs):
    mimetype, encoding = mimetypes.guess_type(path)
    if not mimetype in settings.MIMETYPES.values():
        return staticfiles_serve(request, path, **kwargs)

    bundle = request.GET.get('bundle') in ('1', 't', 'true') or not settings.DEBUG
    asset = finder.find(path, bundle=bundle)
    if not asset:
        raise Http404("Static asset not found")

    # Respect the If-Modified-Since header.
    modified_since = request.META.get('HTTP_IF_MODIFIED_SINCE')
    if not was_modified_since(modified_since, asset.mtime, asset.size):
        return HttpResponseNotModified(content_type=asset.attributes.content_type)

    response = HttpResponse(asset.content, content_type=asset.attributes.content_type)
    response['Last-Modified'] = http_date(asset.mtime)
    response['Content-Length'] = asset.size

    return response

@@ -11,16 +11,68 @@
 etypes%0A%0A
+from django.conf import settings as django_settings%0A
 from dja
@@ -227,23 +227,16 @@
 iews
-.static
  import 
 was_
@@ -235,37 +235,14 @@
 ort 
-was_modified_since, http_date
+static
 %0A%0Afr
@@ -281,16 +281,54 @@
 ettings%0A
+from .exceptions import AssetNotFound%0A
 %0A%0Adef se
@@ -461,16 +461,33 @@
 lues():%0A
+        try:%0A    
         
@@ -535,16 +535,130 @@
 *kwargs)
+%0A        except Http404:%0A            return static.serve(request, path, document_root=django_settings.STATIC_ROOT)
 %0A%0A    bu
@@ -734,16 +734,29 @@
 s.DEBUG%0A
+    try:%0A    
     asse
@@ -800,20 +800,28 @@
     
-if not a
+except A
 sset
+NotFound
 :%0A  
@@ -831,45 +831,83 @@
    r
-aise Http404(%22Static asset not found%22
+eturn static.serve(request, path, document_root=django_settings.STATIC_ROOT
 )%0A%0A 
@@ -1024,16 +1024,23 @@
  if not 
+static.
 was_modi
@@ -1295,16 +1295,23 @@
 ied'%5D = 
+static.
 http_dat

Improve development static view