On Thu, Mar 27, 2008 at 5:12 PM, inhahe <[EMAIL PROTECTED]> wrote:
> here's my code:
>
> class static:
>   def GET(self, tail):
>     if os.path.exists('static\\'+tail):
>       sys.stdout.write(open('static\\'+tail,'r').read())
>     else:
>       web.webapi.notfound()
>        print open('404.html','r').read()
>
>
> ok, i'm trying to test if the file exists in the static directory, and if
> so, send it, and if not, give a 404 response and send 404.html (so that i
> can have uri's without the retarded 'static/' in them)
>
> the problem is it sends 'not found' followed immediately by the contents of
> 404.html.  i don't want the 'not found' there.
>
> that's not the only problem, though.  it doesn't necessarily work right when
> the file actually is there either.
>  i tried loading some images i have in the static directory, and with images
> that are there, 3 different things can happen.
> 1. the images shows correctly
> 2. i get a blank page
> 3. i get something like: The image "http://localhost:8080/vline2.png"; cannot
> be displayed, because it contains errors.
>
> *wonders when the day will come that programming isn't such a pain in the
> arse*
>
>
>  >
>

if you dont want the not found, then why are you calling notfound()?
you're essentially writing your own routing which is unnecessary or
maybe i'm just missing the point.
if not,  just let your webserver do the work. otherwise, you have to
choose a correct header, etc.

so it's clear, here's the source in .23

def notfound():
    """Returns a `404 Not Found` error."""
    ctx.status = '404 Not Found'
    header('Content-Type', 'text/html')
    return output('not found')


-brentp

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

Reply via email to