Skip to content

Instantly share code, notes, and snippets.

@rixx
Created June 18, 2018 22:15

Revisions

  1. rixx created this gist Jun 18, 2018.
    14 changes: 14 additions & 0 deletions urls.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    import os

    from django.http import Http404, FileResponse


    def get_static(request, path, content_type):
    path = os.path.join(settings.BASE_DIR, 'pretalx/static', path)
    if not os.path.exists(path):
    raise Http404()
    return FileResponse(open(path, 'rb'), content_type=content_type)

    urlpatterns = [
    url('^sw.js', get_static, {'path': 'agenda/js/serviceworker.js', 'content_type': 'application/javascript'})
    ]