Google App Engine仅部署* some *图像

时间:2013-09-10 01:07:45

标签: python image web-services google-app-engine caching

我最近使用Google App Engine为我父亲部署了一个网站。

奇怪的是,图库中的一些图像被找到,而一些图像则返回404.我在管理仪表板中查看了使用率,它说我只占“代码和静态文件存储”的17%。 / p>

我已经尝试更改目录并重新部署,我还创建了第二个应用程序(从this-site-1到this-site-2),我等了一个小时,以防它只是缓存,但这些似乎都不是问题。

我是Google App Engine的新手,这是我使用它开发的第一个网站,所以任何帮助都会非常感激。

app.yaml

application: this-site-2
version: 1
runtime: python
threadsafe: true
api_version: 1

handlers:
- url: /robots.txt
  static_files: static/robots.txt
  upload: static/robots.txt

- url: /css
  static_dir: static/css

- url: /img
  static_dir: static/img

- url: /js
  static_dir: static/js

- url: /.*
  script: main.py

编辑:我将python更新为2.7以防出现问题,但我这样做了:

application: this-site-2
version: 1
runtime: python27
threadsafe: true
api_version: 1

handlers:
- url: /robots.txt
  static_files: static/robots.txt
  upload: static/robots.txt

- url: /css
  static_dir: static/css

- url: /img
  static_dir: static/img

- url: /js
  static_dir: static/js

- url: /.*
  script: main.app # a WSGI application in the main module's global scope

libraries:
- name: webapp2
  version: "2.5.1"

- name: django
  version: "1.2"

skip_files:
- ^(.*/)?app\.yaml
- ^(.*/)?app\.yml
- ^(.*/)?index\.yaml
- ^(.*/)?index\.yml
- ^(.*/)?#.*#
- ^(.*/)?.*~
- ^(.*/)?.*\.py[co]
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*
- ^(.*/)?.*\.bak$
- ^(.*/)?.*\.less$

然后我部署了,控制台说部署成功了,它正在更新索引并退出代码0.然后我试着去网站,它返回500 server error。所以我降级回到python 2.5,网站很好。

3 个答案:

答案 0 :(得分:3)

我认为你的图片网址处理程序比它需要的更复杂。我建议:

  1. 将所有静态内容(图片,Javascript,CSS)放在名为static或类似文件夹的文件夹中,包含图片,Javascript和CSS的子文件夹。
  2. 使用以下处理程序代替当前的图像处理程序:

    handlers:
    - url: /images
      static_dir: static/images
    
  3. static/images文件夹中的所有文件都可以在网址yourwebsite.com/images/subpath/image.jpg上访问。

    如需更多灵感,请参阅this app.yaml

答案 1 :(得分:1)

我遇到了这个问题,结果发现它部署了带有小写文件扩展名的图像,如下所示:name.png,而不是像这样的资本文件扩展名:name.PNG。 Windows帮助你隐藏了这一点,所以你总是不能告诉你。

答案 2 :(得分:0)

啊,我爸爸解决了;

只需更改jpg图片即可使用png图片(反之亦然,如果图片png无效,请将其转换为一个jpg