Skip to content

Instantly share code, notes, and snippets.

@KazWolfe
Created March 29, 2017 08:04
Show Gist options
  • Save KazWolfe/fae636a60353343ccbe10a4027814768 to your computer and use it in GitHub Desktop.
Save KazWolfe/fae636a60353343ccbe10a4027814768 to your computer and use it in GitHub Desktop.
Simple echo script that does cool things.
#!/usr/bin/env python
# Echoes the URL back, replacing / with spaces.
# Based off Nathan Hamiel's Reflect script (https://gist.github.com/huyng/814831)
# By Kaz Wolfe, 2017. No rights reserved.
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/plain")
self.end_headers()
self.wfile.write(self.path.replace("/", " ").strip())
port = 9001
print('Listening on localhost:%s' % port)
server = HTTPServer(('', port), RequestHandler)
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment