Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.