views:

86

answers:

2

Hi,

I am unable to display images in pages created using Google App Engine(Python).

My app.yaml file has :

- url: /images
  static_dir: images

And the python file has:

self.response.out.write("""<img src = '/images/title.gif' />""")  

The image still does not display in the page.

Thanks

+1  A: 

I would test:

  1. Do you see http://yourapp.appspot.com/images/title.gif?
  2. Are you sure that images folder is on your app root?
  3. Title.gif is a "working" image?

I would recommend you to use a static folder to store your static contents organized in subfolders:

Root  
  static  
     images
     stylesheets
     javascripts
  app.yaml

and Mapping a url /images like this.

- url: /images
  static_dir: static/images
  mime_type: image/png 

mime_type: image/png is optional; if not specified, the MIME type for a file will be derived from the file's filename extension.

systempuntoout
No he doesn't. If he has a directory called 'images' off his app's root dir, what he's listed should work just fine.
Nick Johnson
You are right, thanks Nick.
systempuntoout
I had the images folder in my root.Root images app.yaml
Milee
A: 

Is there a directory called 'images' in your app's root directory? What does it contain? What do you get if you attempt to fetch the file directly?

Nick Johnson
The images directory is in my root folder. It has the title.gif image. When i run this, the page display but the image doesn't. I am also not able to access it directly,as inhttp://yourapp.appspot.com/images/title.gif
Milee
If the images directory is in your root directory, then the problem is simple: The path you're specifying in app.yaml is static/images, but it's just in 'images'.
Nick Johnson