Reputation: 213
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
Upvotes: 1
Views: 3278
Reputation: 707
One possible reason for this to happen is if you do not provide space between - url
and if you do not restart your server. It will show 404
that time. If you restart your server then you will encounter the error in app.yaml
. This is one very common mistake that people commit. Because the way you have done it seems that it should work fine.
Upvotes: 0
Reputation: 111
I encountered a similar problem. The solution was ultimately very simple. You need to try to reposition the url handler for the static directory before the apphandler for the main.app like this:
handlers:
/favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
/photos
static_dir: photos
.*
script: main.app
This annoyed me for like 45 min before I found the solution on google.
Upvotes: 1
Reputation: 1815
The reason may be about upper/lower case difference between systems. Windows is not upper/lower sensitive, but Linux is. Supposing your actual file name is Title.GIF. It works if it is written as title.gif on a Windows machine (Your Local machine), but does not work on a Linux server (Google App Server).
Upvotes: 0
Reputation: 74054
I would test:
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.
Upvotes: 1
Reputation: 101139
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?
Upvotes: 0