Created
December 4, 2019 15:48
-
-
Save Magicloud/99765a551e0115392881c832d895b19d to your computer and use it in GitHub Desktop.
This file contains 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/python3 | |
from http.server import HTTPServer, BaseHTTPRequestHandler | |
import socket | |
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(200) | |
self.send_header("Content-Type", "text/html") | |
self.end_headers() | |
self.wfile.write(b"<!doctype html><head><title>HOSTNAME</title></head><body><h1>") | |
self.wfile.write(socket.gethostname().encode()) | |
self.wfile.write(b"</h1>") | |
self.wfile.write(self.headers.as_bytes()) | |
self.wfile.write(b"</body></html>") | |
httpd = HTTPServer(("0.0.0.0", 80), SimpleHTTPRequestHandler) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment