def serve(request, path, **kwargs):
    mimetype, encoding = mimetypes.guess_type(path)
    if not mimetype in settings.MIMETYPES.values():
        try:
            return staticfiles_serve(request, path, **kwargs)
        except Http404:
            return static.serve(request, path, document_root=django_settings.STATIC_ROOT)

    bundle = request.GET.get("bundle") in ("1", "t", "true") or not settings.DEBUG
    try:
        asset = finder.find(path, bundle=bundle)
    except AssetNotFound:
        return static.serve(request, path, document_root=django_settings.STATIC_ROOT)

    # Respect the If-Modified-Since header.
    modified_since = request.META.get("HTTP_IF_MODIFIED_SINCE")
    if not static.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"] = static.http_date(asset.mtime)
    response["Content-Length"] = asset.size

    return response
 def test_compile_coffeescript(self):
     self.assertEqual(COFFEESCRIPT_TEST, finder.find('coffeescript.coffee').content.strip('\n'))
 def test_compile_less(self):
     self.assertEqual(LESS_TEST, finder.find('bar.less').content.strip('\n'))
 def test_compile_stylus(self):
     self.assertEqual(STYLUS_TEST, finder.find('stylus.styl').content.strip('\n'))
 def test_compile_sass(self):
     self.assertEqual(SASS_TEST, finder.find('foo.sass').content.strip('\n'))
 def test_compile_jst(self):
     self.assertEqual(JST_TEST, finder.find('templates/list.jst').content.strip('\n'))
 def test_compile_ejs(self):
     self.assertEqual(EJS_TEST, finder.find('templates/detail.ejs').content.strip('\n'))