Skip to content

Instantly share code, notes, and snippets.

@vrutkovs
Last active July 21, 2017 12:23
Show Gist options
  • Select an option

  • Save vrutkovs/f0c0a44c0e796fba0e9085cee1f81781 to your computer and use it in GitHub Desktop.

Select an option

Save vrutkovs/f0c0a44c0e796fba0e9085cee1f81781 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from http.server import BaseHTTPRequestHandler, HTTPServer
import datetime
import sys
total_requests = 0
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
global total_requests
time = datetime.datetime.now().time()
total_requests += 1
print("request #{0} at {1}".format(total_requests, time))
self.send_response(500)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(b"<html><body><h1>OOPSIE</h1></body></html>")
server_address = (sys.argv[1], 8081)
httpd = HTTPServer(server_address, testHTTPServer_RequestHandler)
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment