[英]Python script on server vs. command line
I have a simple hello world python script: 我有一个简单的hello world python脚本:
#!/usr/bin/python
print "Content-Type: text/html"
print
print """\
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
"""
I uploaded it to my server, which has python installed, yet when I visit it in the browser by hitting http://myserver.foo/script.py , I see the script in it's entirety in the browser window. 我将它上传到我安装了python的服务器,但是当我通过点击http://myserver.foo/script.py在浏览器中访问它时,我在浏览器窗口中看到了它的全部内容。 Am I doing something wrong?
难道我做错了什么? I want to just see 'Hello World!'...
我想看看'Hello World!'......
Stupid (but mandatory) questions: 愚蠢(但强制)的问题:
1. Do you have this in either your conf
file or an .htaccess
(assuming Apache)? 1.你的
conf
文件或.htaccess
(假设是Apache)中有这个吗?
AddHandler cgi-script .cgi .py
Options +ExecCGI
2. Have you chmod
'd the file to 755
? 2.您是否
chmod
文件更改为755
?
3. Is Python at /usr/bin/python
? 3. Python在
/usr/bin/python
吗? (It could be C:\\Python32\\python.exe
) (可能是
C:\\Python32\\python.exe
)
Some notes: 一些说明:
#!/usr/bin/env python
instead of #!/usr/bin/python
. #!/usr/bin/env python
而不是#!/usr/bin/python
。 It is more error-proof.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.