如何使我的BlueHost共享帐户服务器与Python脚本一起运行

时间:2019-02-13 14:44:53

标签: python-2.7 apache server httpserver basehttpserver

这是我第一次这样做。我在BlueHost上有一个共享帐户,并且想将托管服务器设置为使用python 2.72。我环顾四周,发现了这个脚本,我对其进行了修改以进行一些测试。经过大量的努力,我使它可以正常运行。问题在于它没有做我要它做的任何事情:

from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer print "starting" class Serv(BaseHTTPRequestHandler):
     print "in the class"
     def do_GET(self):
         print "before the IF"
         if self.path == '/':
             self.path = '/zzindex.html'
             print "zzindex.html  Served"
         try:
             file_to_open = open(self.path[1:]).read()
             self.send_response(200)
             print "SelfResponse 200"
         except:
             file_to_open = "File not found"
             self.send_response(404)
             print "File not found 404"
         self.end_headers()
         self.wfile.write(bytes(file_to_open, 'utf-8'))

 print "Before httpd" httpd = HTTPServer(('localhost', 3000), Serv)
 httpd.serve_forever()

我希望它以URL“ my_domain.com/”运行服务器,并将默认的index.html文件与zzindex.html文件交换,这两个文件都位于my_domain目录中。但是出现的是默认的index.html文件的站点,似乎服务器从未触发动作。而且不会产生错误。

在第一遍中,当我启动服务器时(使用Putty远程连接到BlueHost),来自服务器的唯一打印语句如下:

starting
in the class
Before httpd

此后,服务器正在运行,但服务器未执行任何操作。我尝试使用端口8080,但错误地指出该端口不可用或正在使用。

在相关的情况下,目录的层次结构为:

MainDomain1 >> public_html >> my_domain

Python 2.72安装在MainDomain1 >> public_html >> python

“。bashrc”文件具有以下脚本:

# .bashrc
export PATH=$HOME/python/Python-2.7.2/:$PATH

# User specific aliases and functions
alias mv='mv -i'
alias rm='rm -i'
alias cp='cp -i'


# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

任何帮助将不胜感激。

DK

0 个答案:

没有答案