problem with CGIHTTPServer

7

7stud

1) I have this simple cgi server:


import CGIHTTPServer
import BaseHTTPServer

class MyRequestHandler(CGIHTTPServer.CGIHTTPRequestHandler):
cgi_directories = ['/my_cgi_scripts']

server = BaseHTTPServer.HTTPServer(
('', 8111),
MyRequestHandler
)


server.serve_forever()


2) I have this simple python script:

test.py
--------
#!/usr/bin/env python

import cgitb; cgitb.enable()
import cgi


print "Content-type: text/html"
print
print "hello"


3) I have this simple html page with a link that calls test.py:

<html>
<head>
<title></title>
</head>
<body>

<div>
<a href="http://localhost:8111/my_cgi_scripts/test.py">click me</a>
</div>

</body>
</html>


My directory structure looks like this:

.../dir1
-------myserver.py
-------/my_cgi_scripts
----------------test.py

After I start the server script, load the html page in my browser, and
click on the link, I get the desired output in my browser, but the
server script outputs the following in my terminal:

localhost - - [28/Mar/2008 08:51:22] "GET /my_cgi_scripts/test.py HTTP/
1.1" 200 -
localhost - - [28/Mar/2008 08:51:22] code 404, message File not found
localhost - - [28/Mar/2008 08:51:22] "GET /favicon.ico HTTP/1.1" 404 -


What are the error messages on lines two and three?
 
G

Gabriel Genellina

After I start the server script, load the html page in my browser, and
click on the link, I get the desired output in my browser, but the
server script outputs the following in my terminal:

localhost - - [28/Mar/2008 08:51:22] "GET /my_cgi_scripts/test.py HTTP/
1.1" 200 -
localhost - - [28/Mar/2008 08:51:22] code 404, message File not found
localhost - - [28/Mar/2008 08:51:22] "GET /favicon.ico HTTP/1.1" 404 -


What are the error messages on lines two and three?

Line 3 is your browser (IE, I presume?) asking for an icon for the site.
See http://en.wikipedia.org/wiki/Favicon
I don't know about line 2, maybe it's just a diagnostic message related to
line 3. Try refreshing the page, or using an inexistent url to see if it
still appears. Or put any icon as /favicon.ico to make your browser happy.
 
7

7stud

After I start the server script, load the html page in my browser, and
click on the link, I get the desired output in my browser, but the
server script outputs the following in my terminal:
localhost - - [28/Mar/2008 08:51:22] "GET /my_cgi_scripts/test.py HTTP/
1.1" 200 -
localhost - - [28/Mar/2008 08:51:22] code 404, message File not found
localhost - - [28/Mar/2008 08:51:22] "GET /favicon.ico HTTP/1.1" 404 -
What are the error messages on lines two and three?

Line 3 is your browser (IE, I presume?) asking for an icon for the site.
Seehttp://en.wikipedia.org/wiki/Favicon

Safari.


I don't know about line 2, maybe it's just a diagnostic message related to  
line 3. Try refreshing the page, or using an inexistent url to see if it  
still appears. Or put any icon as /favicon.ico to make your browser happy.

I searched for a .ico file on my computer, then copied it into the
same directory as the server program, and renamed the .ico file:

favcion.ico

Then I loaded my html file in Safari and clicked on the link, and this
was the output:

localhost - - [28/Mar/2008 19:30:31] "GET /my_cgi_scripts/test.py HTTP/
1.1" 200 -
localhost - - [28/Mar/2008 19:30:31] "GET /favicon.ico HTTP/1.1" 200 -

So, it looks like Safari automatically requests a .ico file from a
server. Thanks.
 

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

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top