You're right. I just missed a line before "return f.read()":

   web.header("Content-Type","image/x-icon")

Sure this is not the optimal solution for production, it just answers
the question made by Bruce Eckel, favicon is served entirely by
web.py, no matter if under Apache or not, and is also valid even in
cases in which you are not serving HTML pages.

Thank you!

On Nov 11, 5:09 pm, andrei <andre...@gmail.com> wrote:
> Or setting alias in apache config when in production. I don't think
> streaming favicon through webpy is a good idea.
>
> And your example needs proper content type header.
>
> On Nov 11, 3:25 am, Oscar Ciudad <elc...@gmail.com> wrote:
>
>
>
>
>
>
>
> > A fairly simple solution, not having to put any header HTML header.
> > favicon.ico is supposed to exist under "static":
>
> > import web
>
> > urls = ('/favicon.ico','favicon')
>
> > app = web.application (urls, globals())
>
> > class favicon:
> >     def GET(self):
> >         f = open("static/favicon.ico", 'rb')
> >         return f.read()
>
> > if __name__ == "__main__": app.run()
>
> > On Sep 24, 6:27 am, Bruce Eckel <brucetec...@gmail.com> wrote:
>
> > > I too am curious about this one -- is there some command or code so that
> > > Web.py could serve favicon.ico?
>
> > > -- Bruce Eckelwww.Reinventing-Business.comwww.MindviewInc.com
>
> > > On Fri, Sep 23, 2011 at 3:45 PM, voxtreet <chingweic...@gmail.com> wrote:
> > > > Hi,
>
> > > > Just started using web.py, wrote my first web service in less than 10
> > > > lines, so THANK YOU!
>
> > > > My question is about the favicon.ico file. I built the web app from
> > > > the tutorial, and run it directly from Python using the web.py built-
> > > > in web server. Every time I access the web service from a browser
> > > > (Chrome on Mac), I see in the logs a GET request for the URL I typed
> > > > in, but also see a GET request for /favicon.ico, to which my server
> > > > responds with a 404 Not Found error.
>
> > > > It's not a problem, but it is an annoyance. When I deploy this to
> > > > Apache, I will get an extra line in my error logs every time someone
> > > > visits from a browser.
>
> > > > I know this is a browser-specific issue (trying to find the icon to
> > > > put in the address bar), so not a big deal if requests are coming
> > > > directly from web apps. And I'm sure I could come up with some image
> > > > and install a favicon.ico somewhere and get web.py to serve it up. But
> > > > I'm just wondering if there is some way that web.py can "ignore" these
> > > > requests, or rather, not result in so many 404 errors in my logs? E.g.
> > > > some sort of built-in/default url mapping to some blank .ico data that
> > > > comes with web.py, or something like that?
>
> > > > Thanks!
>
> > > > --
> > > > You received this message because you are subscribed to the Google 
> > > > Groups
> > > > "web.py" group.
> > > > To post to this group, send email to webpy@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > webpy+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/webpy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to webpy@googlegroups.com.
To unsubscribe from this group, send email to 
webpy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to