| import os |
| import hashlib |
| import json |
| |
| |
| def main(request, response): |
| token = request.GET[b'token'] |
| testId = hashlib.md5(token).hexdigest() |
| |
| if request.method == "POST": |
| request.server.stash.take(testId) |
| request.server.stash.put(testId, request.GET[b'value']) |
| response.headers.set(b"Content-Type", b"text/ascii") |
| return b"updated to " + request.GET[b'value'] |
| |
| value = request.server.stash.take(testId) |
| if not value: |
| response.headers.set(b"Cache-Control", b"no-cache") |
| response.headers.set(b"Content-Type", b"text/ascii") |
| return "nothing" |
| |
| response.headers.set(b"Cache-Control", b"no-cache") |
| response.headers.set(b"Content-Type", b"text/html") |
| return "<html><body><script>window.value = '%s';</script></body></html>" % value.decode() |