import json
from wptserve.utils import isomorphic_decode
def main(request, response):
headers = [
(b"Content-Type", b"text/html"),
(b"Cache-Control", b"no-cache, no-store, must-revalidate")
]
key = request.GET.first(b"key", None)
# We serialize the key into JSON, so have to decode it first.
if key is not None:
key = key.decode('utf-8')
body = u"""
""" % (json.dumps({
u"dest": isomorphic_decode(request.headers.get(b"sec-fetch-dest", b"")),
u"mode": isomorphic_decode(request.headers.get(b"sec-fetch-mode", b"")),
u"site": isomorphic_decode(request.headers.get(b"sec-fetch-site", b"")),
u"user": isomorphic_decode(request.headers.get(b"sec-fetch-user", b"")),
}), json.dumps(key))
return headers, body