Created
May 20, 2013 20:48
-
-
Save ispedals/5615420 to your computer and use it in GitHub Desktop.
Example using BaseHTTPServer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | |
from urllib import unquote | |
b=[] | |
class MyHandler(BaseHTTPRequestHandler): | |
def do_GET(self): | |
if not self.path in b: | |
f.write('<li><a href=%s>%s</a></li>\r\n'%(unquote(self.path)[1:],unquote(self.path)[1:])) | |
b.append(self.path) | |
print self.path | |
self.send_response(200) | |
try: | |
server=HTTPServer(('',8080), MyHandler) | |
print 'started' | |
f=open('list.html','a') | |
server.serve_forever() | |
except KeyboardInterrupt: | |
server.socket.close() | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment