Python 2 examples taken while learning SPSE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

19 lines
539 B

#!/usr/bin/python
# -*- coding: utf-8 -*-
import SocketServer
import SimpleHTTPServer
class HttpRequestHandler (SimpleHTTPServer.SimpleHTTPRequestHandler) :
def do_GET(self) :
if self.path == "/admin" :
self.wfile.write('This page is only for admins lol')
self.wfile.write(self.headers)
else :
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
httpServer = SocketServer.TCPServer(("", 7777), HttpRequestHandler)
print "It should listen on 7777."
httpServer.serve_forever()