【发布时间】:2013-10-21 05:09:40
【问题描述】:
我正在使用 Google App Engine 构建我的第一个应用程序并直接遇到问题:我的图像和 css 未加载并出现错误:加载资源失败:服务器响应状态为 404(未找到) .我已经尽我所能尝试解决它,现在我很难过。这是我的代码:
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
目录结构:
phpunionapp\images\logo.png
phpunionapp\stylesheets\style.css
还有日志:
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
浏览器中的404:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:10080/images/logo.png
老实说,我不确定为什么应用程序找不到图像,非常感谢任何帮助!提前致谢。
【问题讨论】:
-
发布服务器日志中显示 404 的行。那里通常有一些有趣的证据。您使用的是哪个版本的 SDK?
-
我已经对其进行了编辑以包含它,你是对的,那里似乎有一些有趣的东西。我使用的是 1.8.5 版
-
日志中的 404 在哪里?可以发一下吗?
-
我已经从pythonware.com/products/pil 安装了 python 2.7 的 PIL 模块(我正在运行)。警告消失了,但仍然没有图像。
-
这里不涉及PIL;该警告与静态图像文件的服务方式无关。
标签: php google-app-engine http-status-code-404 app.yaml