There is a Python 3.5 script using the bottle.py web framework. The Russian text is entered via the textarea form and sent via POST to the server. It is necessary then to display the entered text. Type Crackers are output.

ð ° ððð ðμð ° ðμð ° _sð; 629V_Ble; w

I understand some kind of problem in the encoding. Tell me where to dig? At the beginning of the script is ## - - coding: utf-8 - -.

Here is an example script that lies next to bottle.py:

## -*- coding: utf-8 -*- from bottle import route, run, template, get, post, request @route('/loggen') def loggen(): return template('loggen') @post('/gen') def gen(): fios = request.forms.get('fios') return "<p>"+fios+".</p>" if __name__=='__main__': run(debug=True, reloader=True) 

And this is a template through which we enter text

 <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Генератор логинов</title> </head> <body> <form action="gen" method="post"> <p><h1>Генератор логинов</h1></p> <p><b>Список ФИО:</b></p> <p><textarea class="form-control" rows="15" cols="100" name="fios"> </textarea></p> <p><input type="submit" value="Создать логины"></p> </form> </body> </html> 

    1 answer 1

    The answer was in the Bottle dock http://bottlepy.org/docs/dev/tutorial.html#introducing-forms

    In Python 3 all strings are unicode, but HTTP is a byte-based wire protocol. The strings have to decode the strings somehow before they are passed to the application. To be on the safe side, the WSGI suggests ISO-8859-1 (aka latin1), a reversible single-byte codec. The bottle doesn’t have to be for FormsDict.getunicode () and attribute access control methods. This is not the case.