Answer the question
In order to leave comments, you need to log in
Why is the source code of the cgi script, when requested, displayed in the browser, but the script itself does not display html markup?
I did everything like here: https://pythonworld.ru/web/cgi-1.html
Script code:
print("Content-type: text/html")
print()
print(
"""<html>
<body>
<h1>GOTO HELL</h1>
</body>
</html>""")
from http.server import HTTPServer, CGIHTTPRequestHandler
server_address = ("localhost", 8000)
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
httpd.serve_forever()
Answer the question
In order to leave comments, you need to log in
The script needs to be handled. That is, the web server must understand that this is a script and execute it, and not display it as a page.
Make sure scripts are allowed in your folder
<Directory "/var/www/htdocs/somedir">
Options +ExecCGI
</Directory>
<Directory "/home/*/public_html">
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question