I have the following code as my python server:
#!/usr/bin/python3
from http.server import HTTPServer, CGIHTTPRequestHandler
port = 8080
host_name = "localhost"
httpd = HTTPServer((host_name, port), CGIHTTPRequestHandler)
print("server started, to quit press <ctrl-c>")
httpd.serve_forever()
How do you set the DocumentRoot to which the server is serving the pages from.
The built-in
CGIHTTPRequestHandlerclass serves from the current working directory, which is normally the directory from which you invoked Python.You can use
os.chdir()to change the current working directory.