Skip to content

Instantly share code, notes, and snippets.

@joshkehn
Created October 3, 2011 03:07
Show Gist options
  • Save joshkehn/1258347 to your computer and use it in GitHub Desktop.
Save joshkehn/1258347 to your computer and use it in GitHub Desktop.
import SocketServer
import SimpleHTTPServer
PORT = 1339
def fibonacci (n):
if n < 2:
return 1
else:
return fibonacci(n - 2) + fibonacci(n - 1)
class CustomHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'text/html')
self.end_headers()
self.wfile.write(fibonacci(40))
return
httpd = SocketServer.ThreadingTCPServer(('localhost', PORT),CustomHandler)
print "serving at port", PORT
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment