Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #urls
- url(r'^sw(.*.js)$', views.sw_js, name='sw_js'),
- #views
- from django.views.decorators.cache import never_cache
- from django.template.loader import get_template
- @never_cache
- def sw_js(request, js):
- template = get_template('sw.js')
- html = template.render()
- return HttpResponse(html, content_type="application/x-javascript")
- from django.conf.urls import url
- from django.views.generic import TemplateView
- urlpatterns = [
- # Other urls
- url(r'^service_worker(.*.js)$',
- TemplateView.as_view(template_name='service_worker.js',
- content_type='application/x-javascript'))
- ]
- url(r'^service_worker(.*.js)(?:/(?P<params>[a-zA-Z]+)/)?',
- TemplateView.as_view(template_name='service_worker.js', content_type='application/x-javascript'))
- var url_params = location.search.substring(1);
- console.log(url_params);
- => "foo=bar..."
Add Comment
Please, Sign In to add comment