0
votes

I'm building my first app using Google App Engine and have hit a problem straight off: My images and css are not loading with the error: Failed to load resource: the server responded with a status of 404 (Not Found). I have done all I can think of to try and tackle it, and now I'm stumped. Here's my code:

PHP:

<?php
    echo "<html><header><link rel='stylesheet' type='text/css' href='/stylesheets/style.css'></header>
    <body>
        <div class=header><img src='/images/logo.png'>
        </div><div class=main>hello</div>
    </body></html>";
?>

app.yaml:

application: phpunionapp
version: 1
runtime: php
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /images
  static_dir: static/images

- url: .*
  script: main.php

- url: /stylesheets
  static_dir: stylesheets

Directory Structure:

phpunionapp\images\logo.png
phpunionapp\stylesheets\style.css

And the log:

2013-10-13 16:53:01 Running command: "[u'C:\\Python27\\pythonw.exe', 'C:\\Program Files (x86)\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=10080', '--admin_port=8002', u'C:\\Users\\User\\Documents\\Web Development\\Tests\\phpunionapp']"
INFO     2013-10-13 16:53:03,480 devappserver2.py:660] Skipping SDK update check.
INFO     2013-10-13 16:53:03,520 api_server.py:138] Starting API server at: http://localhost:54192
INFO     2013-10-13 16:53:03,523 dispatcher.py:168] Starting module "default" running at: http://localhost:10080
INFO     2013-10-13 16:53:03,526 admin_server.py:117] Starting admin server at: http://localhost:8002
INFO     2013-10-13 16:53:11,661 module.py:599] default: "GET / HTTP/1.1" 200 191
INFO     2013-10-13 16:53:11,713 module.py:599] default: "GET /images/logo.png HTTP/1.1" 404 -
INFO     2013-10-13 16:53:11,844 module.py:599] default: "GET /stylesheets/style.css HTTP/1.1" 200 191

The 404 in the browser:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:10080/images/logo.png

I am honestly not sure why the app cannot find the images, any help would be very much appreciated! Thanks in advance.

1
Post the lines from the server log that show the 404. There's usually some interesting evidence there. And which version of the SDK are you using?Dave W. Smith
I've edited it to include that and you're right, there seems to be something interesting there. I'm using version 1.8.5Gargleyark
Where' the 404 in the log? Can you post that?Dave W. Smith
I've installed the PIL module for python 2.7 (what I'm running) from pythonware.com/products/pil. The warning is gone but still no images.Gargleyark
PIL isn't involved here; that warning is unrelated to how static image files are served.Dave W. Smith

1 Answers

2
votes

In your app.yaml, change static_dir: static/images to static_dir: images.

I got there by noticing in the logs that the stylesheet was getting served, but the image wasn't. That led back to a difference in app.yaml that I'd missed on first look.