miya3333's picture
Upload 5 files
6a7997c verified
raw
history blame contribute delete
466 Bytes
import http.server
import socketserver
import os
# Define the port Spaces expects applications to run on
PORT = int(os.environ.get("PORT", 7860))
DIRECTORY = "."
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=DIRECTORY, **kwargs)
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Serving directory {DIRECTORY} at port {PORT}")
httpd.serve_forever()