Google App Engine将图片添加到静态文件夹页面 [英] Google App Engine add image to page with static folder
问题描述
我有一个问题,在我的网页中使用静态文件夹路径的图像。
这是我的app.yaml
application:something
version:1
runtime: python27
api_version:1
线程安全:是
处理程序:
- url:/ images
static_dir:static / images
- url:/favicon.ico
static_files:static / favicon.ico
上传:static / favicon.ico
$ b - url:。*
script:main .app
库:
- 名称:webapp2
版本:2.5.2
- 名称:jinja2
版本:latest
我有模板,静态/图像,控制器(有MainHandler.py)文件夹,并且在我的根目录中有main.py和app.yaml文件。在我的模板文件夹中,我有包含以下内容的index.html文件:
< div>
< img src =images / fig1.jpg>
< / div>
我的问题是当页面被加载时,我无法看到我的fig1.jpg图片。
这个网页的网址是什么?如果它看起来像一个子目录,那么为图像使用相对路径不会指向 images
路径。尝试更改为:
< div>
< img src =/ images / fig1.jpg>
< / div>
如果使用Windows,有一个已知的错误。请参阅:
以下错误/ 24107830#24107830> Google App Engine:将不会提供具有以下错误的静态资产:
$ b 尝试添加 mime_type:image / jpeg
到图像处理程序,看看是否是原因。
i have a problem to use image with static folder path in my page. this is my app.yaml
application: something
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /images
static_dir: static/images
- url: /favicon.ico
static_files: static/favicon.ico
upload: static/favicon.ico
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: latest
I have templates, static/images, controllers (has MainHandler.py) folders and in my root i have main.py and app.yaml files. in my templeate folder i have index.html file that contain:
<div>
<img src="images/fig1.jpg">
</div>
my problem is when page was loaded i cant see my fig1.jpg picture.
What is the url of this page? If it looks like a subdirectory, then your using a relative path for your image is not pointing to the images
path. Try changing to:
<div>
<img src="/images/fig1.jpg">
</div>
If using Windows, there is a known bug. See:
Google App Engine: Won't serve static assets with below error:
Try adding mime_type: "image/jpeg"
to your image handler, to see if that is the cause.
这篇关于Google App Engine将图片添加到静态文件夹页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!