Skip to content

Instantly share code, notes, and snippets.

@szaboat
Last active June 29, 2018 13:41
Show Gist options
  • Select an option

  • Save szaboat/fdd0ba52768c93415d5db6367cb088d3 to your computer and use it in GitHub Desktop.

Select an option

Save szaboat/fdd0ba52768c93415d5db6367cb088d3 to your computer and use it in GitHub Desktop.
Http server for testing different http issues
#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
PORT_NUMBER = 8080
class myHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(500)
self.send_header('Content-type', 'application/json')
self.end_headers()
self.wfile.write("{}")
print 'got GET request'
try:
server = HTTPServer(('', PORT_NUMBER), myHandler)
print 'Started httpserver on port ' , PORT_NUMBER
server.serve_forever()
except KeyboardInterrupt:
print '^C received, shutting down the web server'
server.socket.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment