无法在本地主机上执行简单的 python 脚本
Can't execute simple python script on localhost
我正在尝试在我的本地主机上执行简单的 python 脚本。
脚本放在htdocs-> test.py
脚本是:
#!C:\Users\First Last\AppData\Local\Programs\Python\Python37-32\python\python.exe
print("Single Quotes")
在浏览器中点击 http:\localhost\test.py 之前,我启动了 apache 服务器。还在文件末尾添加了以下行:httpd.conf:
AddHandler cgi-script .py
ScriptInterpreterSource 注册表-严格
但是当我在浏览器中点击 http:\localhost\test.py 时,它仍然显示错误:
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
localhost
Apache/2.4.33 (Win32) OpenSSL/1.1.0h PHP/7.2.7
我在网上看了很多文章/帖子来解决这个问题,但仍然无法解决。请帮忙。
您还需要输出 HTTP 响应 headers。
例如:
#!C:\Users\First Last\AppData\Local\Programs\Python\Python37-32\python\python.exe
print("Content-type: text/plain\n")
print("Single Quotes")
我正在尝试在我的本地主机上执行简单的 python 脚本。
脚本放在htdocs-> test.py
脚本是:
#!C:\Users\First Last\AppData\Local\Programs\Python\Python37-32\python\python.exe
print("Single Quotes")
在浏览器中点击 http:\localhost\test.py 之前,我启动了 apache 服务器。还在文件末尾添加了以下行:httpd.conf:
AddHandler cgi-script .py ScriptInterpreterSource 注册表-严格
但是当我在浏览器中点击 http:\localhost\test.py 时,它仍然显示错误:
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
localhost
Apache/2.4.33 (Win32) OpenSSL/1.1.0h PHP/7.2.7
我在网上看了很多文章/帖子来解决这个问题,但仍然无法解决。请帮忙。
您还需要输出 HTTP 响应 headers。
例如:
#!C:\Users\First Last\AppData\Local\Programs\Python\Python37-32\python\python.exe
print("Content-type: text/plain\n")
print("Single Quotes")