Created
May 5, 2021 09:23
-
-
Save rupython/0e033813f4f6427deda16fe39798c8ca to your computer and use it in GitHub Desktop.
From: Мr. Ληdеrsση
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
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