Skip to content

Instantly share code, notes, and snippets.

@rupython
Created May 5, 2021 09:23
Show Gist options
  • Save rupython/0e033813f4f6427deda16fe39798c8ca to your computer and use it in GitHub Desktop.
Save rupython/0e033813f4f6427deda16fe39798c8ca to your computer and use it in GitHub Desktop.
From: Мr. Ληdеrsση
from http.server import BaseHTTPRequestHandler, HTTPServer
import time, ssl
hostName = "localhost"
hostPort = 9000
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(bytes("<html><head><title>Download</title></head>", "utf-8"))
self.wfile.write(bytes("<body><p>File.docx</p>", "utf-8"))
self.wfile.write(bytes("</body></html>", "utf-8"))
myServer = HTTPServer((hostName, hostPort), MyServer)
print(banner)
print(time.asctime(), "Server Starts - " + hostName + ":" + str(hostPort))
try:
myServer.serve_forever()
except KeyboardInterrupt:
print("Goodbay!")
myServer.server_close()
print(time.asctime(), "Server Stops - %s:%s" % (hostName, hostPort))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment