我正在使用python(2.7),webapp2和App Engine在一个项目中进行尝试,其中试图显示一些静态图像,但是bot可以正常工作。
这是我的董事结构:
|Root
├── bp_content
│ └── themes
│ └── default
│ ├── config
│ ├── handlers
│ ├── routes
│ ├── static
│ │ ├── css
│ │ ├── img
│ │ ├── js
│ │ └── less
│ └── templates
│ ├── emails
│ ├── errors
│ └── seo
| └── base.html
| └── home.html
在我项目的根目录下,我有app.yaml
。
这是我的app.yaml
中的一部分:
handlers:
- url: /favicon\.ico
mime_type: image/vnd.microsoft.icon
static_files: bp_content/themes/default/static/favicon.ico
upload: bp_content/themes/default/static/favicon.ico
- url: /(\w*)/favicon\.ico
mime_type: image/vnd.microsoft.icon
static_files: bp_content/themes/\1/static/favicon.ico
upload: bp_content/themes/(\w*)/static/favicon.ico
- url: /(\w*)/(apple-touch-icon.*\.(png))
static_files: bp_content/themes/\1/static/\2
upload: bp_content/themes/(\w*)/static/(apple-touch-icon.*\.(png))
- url: /(robots\.txt|humans\.txt|sitemap\.xml|crossdomain\.xml)
script: main.app
- url: /boilerplate/css
mime_type: text/css
static_dir: bp_includes/static/css
- url: /boilerplate/js
mime_type: text/javascript
static_dir: bp_includes/static/js
- url: /boilerplate/img/(.*\.(gif|png|jpg))
static_files: bp_includes/static/img/\1
upload: bp_includes/static/img/(.*\.(gif|png|jpg))
- url: /(\w*)/css/(.*\.css)$
mime_type: text/css
static_files: bp_content/themes/\1/static/css/\2
upload: bp_content/themes/(\w*)/static/css/(.*\.css)$
- url: /(\w*)/js/(.*\.js)$
mime_type: text/javascript
static_files: bp_content/themes/\1/static/js/\2
upload: bp_content/themes/(\w*)/static/js/(.*\.js)$
- url: /(\w*)/img/(.*\.(gif|png|jpg|jpeg))
static_files: bp_content/themes/\1/static/img/\2
upload: bp_content/themes/(\w*)/static/img/(.*\.(gif|png|jpg|jpeg))
- url: /(\w*)/fonts/(.*\.eot)$
mime_type: application/vnd.ms-fontobject
static_files: bp_content/themes/\1/static/fonts/\2
upload: bp_content/themes/(\w*)/static/fonts/(.*\.eot)
- url: /boilerplate/fonts/(.*\.(eot|svg|ttf|woff))
static_files: bp_includes/static/fonts/\1
upload: bp_includes/static/fonts/(.*\.(eot|svg|ttf|woff))
- url: /(\w*)/fonts/(.*\.otf)$
mime_type: font/opentype
static_files: bp_content/themes/\1/static/fonts/\2
upload: bp_content/themes/(\w*)/static/fonts/(.*\.otf)
- url: /(\w*)/fonts/(.*\.ttf)$
mime_type: application/x-font-ttf
static_files: bp_content/themes/\1/static/fonts/\2
upload: bp_content/themes/(\w*)/static/fonts/(.*\.ttf)
- url: /(\w*)/fonts/(.*\.woff)$
mime_type: application/x-font-woff
static_files: bp_content/themes/\1/static/fonts/\2
upload: bp_content/themes/(\w*)/static/fonts/(.*\.woff)
- url: /(\w*)/fonts/(.*\.svg)$
mime_type: image/svg+xml
static_files: bp_content/themes/\1/static/fonts/\2
upload: bp_content/themes/(\w*)/static/fonts/(.*\.svg)
- url: /.*
script: main.app
我已将图片放置在bp_content -> themes -> default -> static -> img
,然后将其用作:
<img src="../static/img/teamwork1.jpg" alt="" />
答案 0 :(得分:2)
我很确定您的html需要像这样:
In [02]: for book in root.findall('book'):
...: title = book.find('title').text
...: # looping and joining all the authors to make single string
...: author = ', '.join([auth.text for auth in book.findall('author')])
...: year = book.find('year').text
...: price = book.find('price').text
...: print('title: {}\nauthor(s) :{}\nyear: {}\nprice: {}\n\n'.format(title, author, year, price))
...:
title: Everyday Italian
author(s) :Giada De Laurentiis
year: 2005
price: 30.00
title: Harry Potter
author(s) :J K. Rowling
year: 2005
price: 29.99
title: XQuery Kick Start
author(s) :James McGovern, Per Bothner, Kurt Cagle, James Linn, Vaidyanathan Nagarajan
year: 2003
price: 49.99
title: Learning XML
author(s) :Erik T. Ray
year: 2003
price: 39.95
假设您的图片在<img src="/default/img/teamwork1.jpg" alt="" />