本文介绍了Google App Engine - 找不到PHP应用图片/ CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我使用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>; ?> b $ b $ p $ app $ > application:phpunionapp 版本:1 运行时:php api_version:1 线程安全:是 处理程序: - url:/favicon\.ico static_files:favicon.ico 上传:favicon \.ico $ b - url:/ images static_dir: static / images - url:。* script:main.php $ b - url:/ stylesheets static_dir:stylesheets 目录结构: phpunionapp \images\logo.png phpunionapp\stylesheets\style.css 2013-10-13 16:53:01运行命令:[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:\ \\用户\\\用户\\文档\\ Web开发\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' 660]跳过SDK更新检查。 INFO 2013-10-13 16:53:03,520 api_server.py:138]启动API服务器:http:// localhost:54192 INFO 2013-10-13 16:53:03,523调度程序。启动模块默认运行在:http:// localhost:10080 INFO 2013-10-13 16:53:03,526 admin_server.py:117]启动管理服务器:http:// localhost :8002 INFO 2013-10-13 16:53:11,661 module.py:599]默认值:GET / HTTP / 1.1200 191 INFO 2013-10-13 16:53:11,713 module .py:599] default:GET /images/logo.png HTTP / 1.1404 - INFO 2013-10-13 16:53:11,844 module.py:599] default:GET / stylesheets / style .css HTTP / 1.1200 191 404在浏览器中: 加载资源失败:服务器响应状态为404(未找到)http:// localhost:10080 / images / logo.png 我老实说不知道为什么应用程序找不到图片,任何帮助都会非常感谢!在您的 app.yaml 中,更改 code> static_dir:static / images 至 static_dir:images 。 我通过注意到样式表获得服务的日志来到那里,但图像不是。这导致了我在首次查看时错过的 app.yaml 中的差异。 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: phpunionappversion: 1runtime: phpapi_version: 1threadsafe: yeshandlers:- url: /favicon\.ico static_files: favicon.ico upload: favicon\.ico- url: /images static_dir: static/images- url: .* script: main.php- url: /stylesheets static_dir: stylesheetsDirectory Structure:phpunionapp\images\logo.pngphpunionapp\stylesheets\style.cssAnd 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:54192INFO 2013-10-13 16:53:03,523 dispatcher.py:168] Starting module "default" running at: http://localhost:10080INFO 2013-10-13 16:53:03,526 admin_server.py:117] Starting admin server at: http://localhost:8002INFO 2013-10-13 16:53:11,661 module.py:599] default: "GET / HTTP/1.1" 200 191INFO 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 191The 404 in the browser:Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:10080/images/logo.pngI am honestly not sure why the app cannot find the images, any help would be very much appreciated! Thanks in advance. 解决方案 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. 这篇关于Google App Engine - 找不到PHP应用图片/ CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-31 06:50