jukebox-software/fileserver.py
2024-05-08 13:27:45 -05:00

17 lines
494 B
Python

import http.server
import socketserver
import os
def run_server(port, directory):
"""
Run a simple HTTP server serving files from the specified directory.
"""
# Change the working directory to the specified directory
os.chdir(directory)
# Create the HTTP server
handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", port), handler) as httpd:
print(f"Serving cable images & files at port {port}")
httpd.serve_forever()