Answer the question
In order to leave comments, you need to log in
Running cgi python script from pycharm and console, how to display Cyrillic?
Hello everyone, such a problem, I launch the built-in localhost python server, in the cgi folder there is a script that, when accessed from a browser, gives a filled html table in which the information is in Russian. So, if I run it from pycharm (where I actually write the code), then the Cyrillic alphabet in the browser is displayed normally, if I run it from the console, black diamonds with question marks are displayed instead of Cyrillic characters in the browser. I have no idea what to do, newbie.
There is a project folder, in its root is the main.py file and the cgi-bin folder
. The following code is in the main.py file:
from http.server import HTTPServer, CGIHTTPRequestHandler
server_address = ("", 8000)
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
httpd.serve_forever()
print("Content-type: text/html; charset=utf-8")
print()
print("проверка")
Answer the question
In order to leave comments, you need to log in
In order for your code to work correctly in the console, then bring the file to this form:
#!/usr/bin/python
# -*- coding: utf-8 -*-
print("Content-type: text/html; charset=utf-8")
print()
print("проверка")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question