blob: ebee4ff8e8da785cf4b4a339c6514b5fe9b98f9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import random
import time
body = u'''
onactivate = (e) => e.waitUntil(clients.claim());
var resolve_wait_until;
var wait_until = new Promise(resolve => {
resolve_wait_until = resolve;
});
onmessage = (e) => {
if (e.data == 'wait')
e.waitUntil(wait_until);
if (e.data == 'go')
resolve_wait_until();
};'''
def main(request, response):
headers = [(b'Cache-Control', b'no-cache, must-revalidate'),
(b'Pragma', b'no-cache'),
(b'Content-Type', b'application/javascript')]
skipWaiting = u''
if b'skip-waiting' in request.GET:
skipWaiting = u'skipWaiting();'
return headers, u'/* %s %s */ %s %s' % (time.time(), random.random(), skipWaiting, body)
|