带有Google App Engine的静态图片文件夹 [英] Static image folder with google app engine

查看:81
本文介绍了带有Google App Engine的静态图片文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经有很多关于这个问题的文章,但是我找不到解决问题的方法.我正在使用Google App Engine启动器使用python创建小型Web应用程序.我需要在页面上显示图片(/images/chartname.png ).我正在使用以下html代码行< img width = 150 src ="/images/chartname.png"> ,但图片没有显示.另外,当我打开 http://localhost:8080/images 时,我收到错误404.

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.

这是我的 .yaml 文件的内容:

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

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

- url: /images
  static_dir: images

我不明白为什么图片不显示以及为什么 http://localhost:8080/images 返回错误404.

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

我已经尝试了这篇文章中的建议: Google App Engine将图片添加到带有静态文件夹的页面中,但它对我没有帮助.

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.

推荐答案

尝试重新排序处理程序:

Try reordering the handlers:

- url: /images
  static_dir: images

- url: /.*
  script: app.my_app

按照从顶部到底部在app.yaml文件中出现的顺序对样式进行评估.模式与URL匹配的第一个映射是用于处理请求的映射.

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.

这篇关于带有Google App Engine的静态图片文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆