So that`s hard to   choice another path for my image , css , js file .
right ?


class images:
    def GET(self,name):
        ext = name.split(".")[-1] # Gather extension
        print '2222',name
        cType = {
            "png":"images/png",
            "jpg":"image/jpeg",
            "gif":"image/gif",
            "ico":"image/x-icon"            }

        if name in os.listdir('images'):  # Security
            web.header("Content-Type", cType[ext]) # Set the Header
            return open('images/%s'%name,"rb").read() # Notice 'rb'
for reading images
        else:
            web.notfound()

URL :  http://webpy.org/images

Could we implement by this way ?

On May 7, 1:38 pm, Alice Zoë Bevan–McGregor <[email protected]>
wrote:
> > On May 7, 1:15 pm, magix <[email protected]> wrote:
> >> I wanna to add css , js and image folder to web.py project . but who
> >> to configure it ?
>
> > You need cookbook:http://webpy.org/cookbook/staticfiles
>
> The cookbook doesn't provide an example of my use case: I need static  
> files served from a Python .egg package, not from a path relative to  
> the script calling the run method of the application object.
>
>         — Alice.
>
>  smime.p7s
> 2KViewDownload
--~--~---------~--~----~------------~-------~--~----~
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