This is using python 2.7.6
I'm trying to serve files from my local, current working directory. I'm attempting to set up a server that runs from this directory, but have not been able to get any of its files to display.
I've been attempting to run the code found here to set up a server that listens for http requests in the current directory, but haven't had any luck getting the files to display.
I've been trying to display the html file images.html
that exists in this directory, but when I run the following script and navigate to 127.0.0.1:8000/images.html in my browser, I just get a blank page. This also occurs when trying to navigate to 127.0.0.1:8000/ to display the directory contents.
import SocketServer
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
print self.path
self.send_response(200)
httpd = SocketServer.TCPServer(("", 8000), MyHandler)
httpd.serve_forever()
The server is running as when I do navigate to 127.0.0.1:8000/images.html I get the expected command line output:
127.0.0.1 - - [29/May/2015 20:03:43] "GET /images.html HTTP/1.1" 200 -
/images.html
However, if I run
python -m SimpleHTTPServer 8000
from the current directory and navigate to 127.0.0.1:8000/images.html, the html file does display as expected.
What am I missing?