Last active
January 11, 2024 21:04
-
-
Save andreif/439157471eabc54728cbd00eb32b4bff to your computer and use it in GitHub Desktop.
Revisions
-
andreif revised this gist
Jan 11, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ python -m http.server -d /tmp 8080 -
andreif revised this gist
Jan 11, 2024 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,11 @@ def app(environ, start_response): start_response('200 OK', [('Content-Type', 'application/json; charset=utf-8')]) return [b'true'] simple_server.ServerHandler.server_software = '' with simple_server.make_server(host='0.0.0.0', port=8080, app=app) as _: print(f"Serving on port {_.server_port}...") _.serve_forever() -
andreif revised this gist
Jan 11, 2024 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ from wsgiref import simple_server def app(environ, start_response): start_response("200 OK", [("Content-Type", "application/json; charset=utf-8")]) return [b"true"] simple_server.ServerHandler.server_software = "" with simple_server.make_server(host="0.0.0.0", port=8080, app=app) as _: print(f"Serving on port {_.server_port}...") _.serve_forever() -
andreif revised this gist
Jan 11, 2024 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ import http.server class Handler(http.server.BaseHTTPRequestHandler): def __getattr__(self, item): if item.startswith('do_'): return self.default @@ -18,9 +18,9 @@ def default(self): self.wfile.write(b'ok') with http.server.ThreadingHTTPServer(('0.0.0.0', 8080), RequestHandlerClass=Handler) as _: print(f"Serving on port {_.server_port}...") try: _.serve_forever() except KeyboardInterrupt: exit(0) -
andreif created this gist
Jan 11, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ import http.server as s class RequestHandler(s.BaseHTTPRequestHandler): def __getattr__(self, item): if item.startswith('do_'): return self.default return getattr(super(), item) def default(self): print(self.command, self.path) print(self.headers) self.protocol_version = 'HTTP/1.0' self.send_response(200) self.send_header('a', '1') self.send_header('a', '2') self.end_headers() self.wfile.write(b'ok') with s.ThreadingHTTPServer(('0.0.0.0', 8080), RequestHandlerClass=RequestHandler) as h: print(f"Serving on port {h.server_port}...") try: h.serve_forever() except KeyboardInterrupt: exit(0)