Google App Engine Static Files GET 404

2020-06-12 06:19发布

问题:

The following app.yaml works great on my local dev server.. but when I deploy it to production all static files throw 404. Server isn't able to locate any static files. Have been searching for hours couldn't find a valid solution.

Note: I am developing with mac, so aware of the case sensitive nature of the system.

application: dev-scanner
version: 1
runtime: python
api_version: 1

handlers:
- url: /(.+)
  static_files: static_files/\1
  upload: ./static_files/(.+)

- url: /
  static_files: static_files/index.html
  upload: ./static_files/index.html

Here is the error from the log

2011-03-18 01:18:07.033 / 404 21ms 0cpu_ms 0kb Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.134 Safari/534.16,gzip(gfe),gzip(gfe),gzip(gfe) 76.126.174.202 - - [18/Mar/2011:01:18:07 -0700] "GET / HTTP/1.1" 404 0 - "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.134 Safari/534.16,gzip(gfe),gzip(gfe),gzip(gfe)" "dev.app-scanner.com" ms=21 cpu_ms=0 api_cpu_ms=0 cpm_usd=0.000053 W 2011-03-18 01:18:07.012 Static file referenced by handler not found: static_files/index.html

Here is the file system structure after I use appcfg.py download_app -A

回答1:

Take a look at the app.yaml in this gist:

https://gist.github.com/873098

It successfully serves a static site. The main differences I see are the lack of the './' as noted by @Wooble above, and the use of (.*) instead of (.+) as the main regular expression. (.+) should work in theory though.