Problem - Serving web pages on the desktop (SimpleHTTPServer)

T

test

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: webbrowser-test.py

import webbrowser, SimpleHTTPServer
from StringIO import StringIO

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

class MyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def send_head(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
return StringIO(myPage)
webbrowser.open("http://127.0.0.1:8000", new=0, autoraise=1)
SimpleHTTPServer.test(MyRequestHandler)

--------------------

Here's my sample directory:
---------------------------------
webbrowser-test.py
testpage.html
m_files/
|_____stylesheet.css
|_____logo.gif
--------------------------------

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.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top