import base64
import sys
encoded = base64.b64encode(sys.stdin.read())
print(encoded)
decoded = base64.b64decode(encoded)
print(decoded)
How does one encode and decode a string with Python for use in a URL?