Kunal
Kunal

Reputation: 59

i am trying to create a http server in python using SimpleHTTPServer and getting error

Here is my code:

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()

I am getting the error 'module' object has no attribute 'SimpleHttpRequestHandler', why is this error occurring?

Thanks in advance

Upvotes: 0

Views: 758

Answers (1)

Tom Wyllie
Tom Wyllie

Reputation: 2085

It is SimpleHTTPRequestHandler not SimpleHttpRequestHandler, the HTTP is uppercase.

Upvotes: 2

Related Questions