Currently if I go to "http://localhost:8035/", I can see and have access to all the files, including root directory, client_files directory, and server_files directory(i.e. I have access to all files, folders, and all its subdirectories, etc).
Goal: I want to limit the file access to only the files in the client_files directory. Is there a way to do that with the current code I have?
Current Directory Structure:
Current Code (run_server.py - located in root directory):
from http.server import HTTPServer, SimpleHTTPRequestHandler
class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Methods', 'GET')
self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate')
return super(CORSRequestHandler, self).end_headers()
def func_run_server(url, port):
httpd = HTTPServer((url, port), CORSRequestHandler)
httpd.serve_forever()
func_run_server('localhost', 8035)
