I have a simple hello world python script:
#!/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. Am I doing something wrong? I want to just see 'Hello World!'...
Stupid (but mandatory) questions:
1. Do you have this in either your conf
file or an .htaccess
(assuming Apache)?
AddHandler cgi-script .cgi .py
Options +ExecCGI
2. Have you chmod
'd the file to 755
?
3. Is Python at /usr/bin/python
? (It could be C:\\Python32\\python.exe
)
Some notes:
#!/usr/bin/env python
instead of #!/usr/bin/python
. It is more error-proof.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.