Base64 encode

This commit is contained in:
redfast00 2019-08-02 20:38:56 +02:00
parent 51d66e5317
commit a9e91563f2
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C

View file

@ -9,6 +9,7 @@ from collections import defaultdict
import mpd import mpd
from urllib.parse import urlencode from urllib.parse import urlencode
from urllib.request import Request, urlopen from urllib.request import Request, urlopen
import base64
mpc = mpd.MPDClient() mpc = mpd.MPDClient()
mpc.timeout = 0.2 mpc.timeout = 0.2
@ -90,7 +91,7 @@ def messages_post():
messages.append(Message(time, sender, sendertype, str(message, "UTF-8"))) messages.append(Message(time, sender, sendertype, str(message, "UTF-8")))
url = 'http://10.0.5.42:8000/' # Set destination URL here url = 'http://10.0.5.42:8000/' # Set destination URL here
post_fields = {'X-Messages': message} # Set POST fields here post_fields = {'X-Messages': base64.b64encode(message)} # Set POST fields here
request = Request(url, urlencode(post_fields).encode()) request = Request(url, urlencode(post_fields).encode())
json = urlopen(request).read().decode() json = urlopen(request).read().decode()