tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

export-on-load-script.py (722B)


      1 import datetime
      2 
      3 def main(request, response):
      4    # This script serves both preflight and main GET request for cross-origin
      5    # static imports from module service workers.
      6    # According to https://w3c.github.io/ServiceWorker/#update-algorithm,
      7    # `Service-Worker: script` request header is added, which triggers CORS
      8    # preflight.
      9    response_headers = [(b"Content-Type", b"text/javascript"),
     10                        (b"Access-Control-Allow-Origin", b"*"),
     11                        (b"Access-Control-Allow-Headers", b"Service-Worker")]
     12 
     13    body = b"export const importedModules = ['export-on-load-script.js'];"
     14    body += b"// %d" % datetime.datetime.now().timestamp()
     15    return (200, response_headers, body)