[英]What do I need to configure to run Python on a browser?
I have worked with Python for a while, but this is my first time that I have to install it and use it on a VPS server.我已经使用 Python 有一段时间了,但这是我第一次必须安装它并在 VPS 服务器上使用它。
I have the following script hello.py
:我有以下脚本
hello.py
:
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
print '''
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>'''
print "Hello World!"
I haven't been able to run the file on a browser.我无法在浏览器上运行该文件。 I don't know if it has something to do with the location of the script or with some other permissions I need to consider.
我不知道它是否与脚本的位置或我需要考虑的其他一些权限有关。 I think there is nothing wrong with the code, because I copy exactly the same in another server (which I didn't configure) it works fine.
我认为代码没有问题,因为我在另一台服务器(我没有配置)中复制完全相同,它工作正常。 Also, If I run the script from the console, it also works.
此外,如果我从控制台运行脚本,它也可以工作。
If I run the file on the location project/cgi-bin/hello.py
the browsers display "Internal Server Error".如果我在位置
project/cgi-bin/hello.py
上运行该文件,浏览器会显示“内部服务器错误”。 In console the error is: No such file or directory: exec of /project/cgi-bin/hello.py
.在控制台中,错误是:
No such file or directory: exec of /project/cgi-bin/hello.py
。
If I run the file on the location project/hello.py
the browser displays plain text.如果我在位置
project/hello.py
上运行该文件,浏览器将显示纯文本。
I've been reading a lot, and I think that maybe the problem has to do with some configuration on de HTTP, or Apache2 directory.我读了很多书,我认为问题可能与 de HTTP 或 Apache2 目录上的某些配置有关。
I would greatly appreciate your help.非常感谢您的帮助。
You don't do anything.你什么都不做。 Python does not and cannot run in a browser.
Python 不能也不能在浏览器中运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.