Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > problem with CGIHTTPServer

Reply
Thread Tools

problem with CGIHTTPServer

 
 
7stud
Guest
Posts: n/a
 
      03-28-2008

1) I have this simple cgi server:


import CGIHTTPServer
import BaseHTTPServer

class MyRequestHandler(CGIHTTPServer.CGIHTTPRequestHandl er):
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?

 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      03-28-2008
En Fri, 28 Mar 2008 12:38:45 -0300, 7stud <>
escribió:

> 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.

--
Gabriel Genellina

 
Reply With Quote
 
 
 
 
7stud
Guest
Posts: n/a
 
      03-29-2008
On Mar 28, 10:12*am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
> En Fri, 28 Mar 2008 12:38:45 -0300, 7stud <bbxx789_0...@yahoo.com> *
> escribió:
>
> > 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redhat 9, Python 2.4.1, CGIHTTPServer problem Bill Oldroyd Python 1 04-20-2005 03:05 PM
Problem with py2exe-frozen CGIHttpServer-based script vincent wehren Python 3 11-27-2003 05:46 PM
Re: Securing PyDoc and CGIHTTPserver Peter Hansen Python 7 07-15-2003 01:03 PM
CGIHTTPserver looze PYTHONPATH vincent delft Python 1 07-13-2003 06:07 PM
Re: Securing PyDoc and CGIHTTPserver Shane Hathaway Python 1 07-11-2003 05:05 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57