10
votes

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

enter image description here

1
What happens if you change static_files on the yaml to static_dir?Jorge Guberte
./ is redundant. I'm not sure it's causing your problem, but I'd try removing it.Wooble
I'm a bit late, but I'd like to note that I had the same problem with a different solution. For future readers: double check to make sure your includes and your file names match up exactly (INCLUDING case). I was developing on Windows (sorry) and thought image.PNG would be recognized the same as image.png, but GAE's environment distinguishes between the two.Matthew R.

1 Answers

7
votes

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.