Last active
July 21, 2017 12:23
-
-
Save vrutkovs/f0c0a44c0e796fba0e9085cee1f81781 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| 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