I think I found the answer to this question, mainly due to changing the current working directory, starting the server and then returning to the original working directory.
Here is how I achieved this, I commented on two sets of options for you, since the solution for me simply moved to a folder in my application directory and then returned one level to the original application directory. But you might want to go to the whole other directory in your file system and then go back somewhere else or not.
#Setup file server import SimpleHTTPServer import SocketServer import os PORT = 5002 # -- OPTION 1 -- #os.chdir(os.path.join(os.path.abspath(os.curdir),'PATH_TO_FOLDER_IN_APP_DIR')) # -- OPTION 2 -- #os.chdir('PATH_TO_ROOT_DIRECTORY') Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("", PORT), Handler) print "serving at port", PORT httpd.serve_forever() # -- OPTION 1 -- #os.chdir(os.path.abspath('..')) # -- OPTION 2 -- #os.chdir('PATH_TO_ORIGINAL_WORKING_DIR')
Let me know how it works!
source share