problem with CGIHTTPServer

Discussion in 'Python' started by 7stud, Mar 28, 2008.

  1. 7stud

    7stud Guest

    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?
    7stud, Mar 28, 2008
    #1
    1. Advertising

  2. 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
    Gabriel Genellina, Mar 28, 2008
    #2
    1. Advertising

  3. 7stud

    7stud Guest

    On Mar 28, 10:12 am, "Gabriel Genellina" <>
    wrote:
    > 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.
    > 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.
    7stud, Mar 29, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Hansen

    Re: Securing PyDoc and CGIHTTPserver

    Peter Hansen, Jul 10, 2003, in forum: Python
    Replies:
    7
    Views:
    420
    Peter Hansen
    Jul 15, 2003
  2. Shane Hathaway

    Re: Securing PyDoc and CGIHTTPserver

    Shane Hathaway, Jul 10, 2003, in forum: Python
    Replies:
    1
    Views:
    370
    Shane Hathaway
    Jul 11, 2003
  3. vincent delft

    CGIHTTPserver looze PYTHONPATH

    vincent delft, Jul 13, 2003, in forum: Python
    Replies:
    1
    Views:
    440
    vincent_delft
    Jul 13, 2003
  4. vincent wehren
    Replies:
    3
    Views:
    398
    vincent wehren
    Nov 27, 2003
  5. Bill Oldroyd
    Replies:
    1
    Views:
    385
Loading...

Share This Page