18 lines
		
	
	
		
			536 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			536 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.makedirs(directory, exist_ok=True)
 | |
|     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()
 |