我试图使用SimpleHTTPServer在python中创建一个http服务器并获取错误

时间:2017-07-19 10:23:53

标签: python

这是我的代码:

import SocketServer
import SimpleHTTPServer

class HttpRequestHandler(SimpleHTTPServer.SimpleHttpRequestHandler) :

    def do_GET(self) :

            if self.path == '/admin' :
                    print "This page is only for admins"

            else :
                    SimpleHTTPServer.SimpleHttpRequestHandler(self)

addr = (('0.0.0.0',10001))
httpServer = SocketServer.TCPServer(addr,HttpRequestHandler)
httpServer.serve_forever()

我收到错误'module' object has no attribute 'SimpleHttpRequestHandler',为什么会出现此错误?

提前致谢

1 个答案:

答案 0 :(得分:0)

SimpleHTTPRequestHandler不是SimpleHttpRequestHandlerHTTP是大写的。