Problem - Serving web pages on the desktop (SimpleHTTPServer)

test at test.test test at test.test
Tue May 9 07:41:51 CEST 2006

Hi there,

Perhaps someone can help me. For some reason, when my Python script
runs and loads an HTML page in a new browser window at the local host
(desktop), the links to my stylesheet and all the images are broken. I
did check the HTML file by itself...everything loaded fine ;)

Here's my script:
# File:

import webbrowser, SimpleHTTPServer
from StringIO import StringIO

f=open('testpage.html', 'rb')
myPage =

class MyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def send_head(self):
        self.send_header("Content-type", "text/html")
        return StringIO(myPage)"", new=0, autoraise=1)


Here's my sample directory:

Thanks for having a look. My next step is to process form input using
AJAX. I'll post working snippets of code here as I progress.


More information about the Python-list mailing list