S
S
ssssergey2015-04-14 23:51:46
Flask
ssssergey, 2015-04-14 23:51:46

Why does the Flask server throw an error when using Cyrillic in a dictionary?

When you try to access the dictionary (TOPIC_DICT) by the key in Russian ("Key"), the server gives an error (Internal Server Error). And everything works in English. UTF-8 is set everywhere in the code. Notepad++ also uses UTF-8. Russian text in normal HTML code is displayed without errors.

{% for t in TOPIC_DICT["Ключ"] %}
    <li><a href="{{t[1]}}">{{t[0]}}</a></li>
  {% endfor %}


Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

I am taking a training course on the YouTube channel - Sentdex.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
ssssergey, 2015-04-16
@ssssergey

Found a solution. You need to write with u, i.e. u"Key"

Z
zelsky, 2015-04-15
@zelsky

Base in Utf-8 ?

Z
zedzew, 2015-04-16
@zedzew

# -*- coding: utf-8 -*-

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question