Skip to content

Instantly share code, notes, and snippets.

@ispedals
Created May 20, 2013 20:48
Show Gist options
  • Save ispedals/5615420 to your computer and use it in GitHub Desktop.
Save ispedals/5615420 to your computer and use it in GitHub Desktop.
Example using BaseHTTPServer
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