Skip to content

Instantly share code, notes, and snippets.

@marduc812
Last active December 9, 2020 16:38
Show Gist options
  • Save marduc812/a8e24b9b8ff79250d2f9d0835fca7f12 to your computer and use it in GitHub Desktop.
Save marduc812/a8e24b9b8ff79250d2f9d0835fca7f12 to your computer and use it in GitHub Desktop.
Snippet for sending every status code needed using Python'
from http.server import HTTPServer, BaseHTTPRequestHandler
ADDRESS = ""
PORT = 8000
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
# Select the HTTP Response needed, currently it's 204
self.send_response(204)
def run(server_class=HTTPServer, handler_class=BaseHTTPRequestHandler):
server_address = (ADDRESS, PORT)
httpd = server_class(server_address, handler_class)
httpd.serve_forever()
if __name__ == '__main__':
run(handler_class=RequestHandler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment