Created
March 29, 2017 08:04
-
-
Save KazWolfe/fae636a60353343ccbe10a4027814768 to your computer and use it in GitHub Desktop.
Simple echo script that does cool things.
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
#!/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