Skip to content

Instantly share code, notes, and snippets.

@mrcnc
Created November 26, 2018 19:53
Show Gist options
  • Save mrcnc/9d3f91737f0e5d5c6fc3c0dcc8a6000a to your computer and use it in GitHub Desktop.
Save mrcnc/9d3f91737f0e5d5c6fc3c0dcc8a6000a to your computer and use it in GitHub Desktop.
a simple server that runs in python2 that always returns a 500 (useful for testing)
import BaseHTTPServer
HOST = "0.0.0.0"
PORT = 8000
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(500)
self.send_header("Content-type", "text/plain")
self.end_headers()
self.wfile.write("Internal Server Error\n")
if __name__ == "__main__":
httpd = BaseHTTPServer.HTTPServer((HOST, PORT), MyHandler)
print("Test server started on {}:{}".format(HOST, PORT))
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment