fixed utf-8 decoding of toot content

This commit is contained in:
theo1 2020-10-01 19:53:50 +02:00
parent 4fc2a6c50f
commit a4a9163efc
2 changed files with 5 additions and 3 deletions

2
app.py
View File

@ -18,5 +18,7 @@ def toot():
toot_content = request.data toot_content = request.data
if(toot_content == None): if(toot_content == None):
return "No content, aborting" return "No content, aborting"
toot_content = toot_content.decode("utf-8")
print(toot_content)
print(mastodon.status_post(toot_content, spoiler_text="Musique")) print(mastodon.status_post(toot_content, spoiler_text="Musique"))
return "Tooted !" return "Tooted !"

View File

@ -7,7 +7,7 @@ function tootInfo(message) {
url = "http://localhost:5000/toot" url = "http://localhost:5000/toot"
fetch(url, { fetch(url, {
method: 'POST', method: 'POST',
body: JSON.stringify(tootContent), body: tootContent
}) })
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
@ -18,8 +18,8 @@ function tootInfo(message) {
} }
function handleResponse(message) { function handleResponse(message) {
document.getElementById("toot-info").innerHTML = message.artist + " - " + message.title document.getElementById("toot-info").innerHTML = message.artist + " - " + message.title + '\n\n'
document.getElementById("toot-hashtags").value = "#radio #np #musique #music" document.getElementById("toot-hashtags").value = "#radio #np #musique #music" + '\n'
} }
function handleError(error) { function handleError(error) {