0
I am sending the segiunte string via post (Javascript) to my server Bootle(Python):
query = {
'wiki': `Tr%E1%BA%A7n_H%C6%B0ng_%C4%90%E1%BA%A1o`,
'uid':'f17afd66aae3a'
}
$.post(url, query, function(data, status){}):
But when I print what I get from the post gives the following result:
b'uid=f17afd66aae3a&wiki=Tr%25E1%25BA%25A7n_H%25C6%25B0ng_%25C4%2590%25E1%25BA%25A1o'
- First print
In case I do two split transforming this binary string into a dictionary through the function translate(postdata)
.
{'uid': 'f17afd66aae3a', 'wiki': 'Tr%25E1%25BA%25A7n_H%25C6%25B0ng_%25C4%2590%25E1%25BA%25A1o'}
- Second print
And how my code will access the wikipedia article with such name:
https://en.wikipedia.org/wiki/Tr%E1%BA%A7n_H%C6%B0ng_%C4%90%E1%BA%A1o
I can’t access it because my request has the following url:
https://en.wikipedia.org/wiki/Tr%25E1%25BA%25A7n_H%25C6%25B0ng_%25C4%2590%25E1%25BA%25A1o
Which generates an error because there is no page.
There’s my code on the Bottle:
@post('/update_article')
@enable_cors
def update_article_post():
token = request.cookies.get('token', '0')
if load_token(token):
postdata = request.body.read()
print(postdata)
dici = translate(postdata)
print(dici)
# res = update_article(dici['uid'], dici['wiki'])
# return {'data': res}
else:
return redirect('/login.html')
Is there any way to receive the post the right way, or encode that string?