Static image folder with google app engine

喜欢而已 提交于 2021-01-29 03:17:32

问题


There are already a lot of post dealing with this issue but I wasn't able to find a solution to my problem. I am using the Google App Engine Launcher to create a small web application using python. I need to display a picture (/images/chartname.png) on my page. I am using the following line of html code <img width=150 src="/images/chartname.png"> but the picture does not show up. Additionally when I open http://localhost:8080/images I get an error 404.

Here's the content of my .yaml file:

application: app
version: 1
runtime: python27
api_version: 1
threadsafe: false

handlers:
- url: /.*
  script: app.my_app

- url: /images
  static_dir: images

I don't understand why the picture doesn't show up and why http://localhost:8080/images returns an error 404.

I've tried the suggestion in this post: Google App Engine add image to page with static folder but it didn't do it for me.


回答1:


Try reordering the handlers:

- url: /images
  static_dir: images

- url: /.*
  script: app.my_app

Patterns are evaluated in the order they appear in the app.yaml file, from top to bottom. The first mapping whose pattern matches the URL is the one used to handle the request.



来源:https://stackoverflow.com/questions/41685729/static-image-folder-with-google-app-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!