App Engine YAML文件未运行脚本 [英] App Engine YAML file not running scripts

查看:70
本文介绍了App Engine YAML文件未运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有其他静态文件在域中正常运行.

All other static files are serving as normal at domain.

似乎PHP文件未运行;当我不尝试将其作为脚本运行(而是将其作为静态文件上传)时,它可以正常工作;当jQuery调用它时返回纯文本-因此它绝对不是文件路径问题.

It seems PHP file wasn't running; when I don't try to run it as a script (and just upload it as a static file) it works fine; returning plaintext when jQuery calls it - so its definitely not a file path problem.

但是一旦我将其作为yaml中的php文件列出,并期望jQuery能够获得你好,世界!"它会在Firefox网络监视器中返回404,并且控制台中没有任何响应.

But once I list it as a php file in yaml and expect the jQuery to GET 'hello, world!' it returns 404 in the Firefox network monitor and there's a no response in the console.

在App Engine Standard上运行单独的服务器端php脚本时,我是否缺少某些东西?

Is there something I'm missing with regard to running a solitary server-side php script on App Engine Standard?

app.yaml

runtime: php55
api_version: 1
threadsafe: true

handlers:
# Serve php scripts another way.
- url: /scripts/elastic.php
  script: scripts/elastic.php

# Handle the main page by serving the index page.
# Note the $ to specify the end of the path, since app.yaml does prefix matching.
- url: /$
  static_files: index.html
  upload: index.html


# Handle folder urls by serving the index.html page inside.
- url: /(.*)/$
  static_files: \1/index.html
  upload: .*/index.html

# Handle nearly every other file by just serving it.
- url: /(.+)
  static_files: \1
  upload: (.*)

elastic.php

<?php
return 'Hello, world!'
?>

script.js(在jQuery加载到我的index.html中之后调用)

$(document).ready(function(){
    $.get("./scripts/elastic.php", function( data ) {
      console.log(data);
    });
});

推荐答案

我认为正在发生的事情是您的最终 handlers 指令告诉部署将应用程序中的所有文件视为可上传且静态的.我相信这会导致您对早期脚本的调用处理不当(可能是App Engine错误...).

What I think is happening is that your final handlers directive is telling the deployment to treat all files in your application as uploadable and static. I believe this is resulting in your calls to the earlier script being mishandled (maybe an App Engine bug...).

如果将最终处理程序更改为PHP脚本或类似以下内容,那么您应该会很好:

If you change your final handler to be either a PHP script or something like the following then you should be mostly good:

- url: /(.*)
  static_files: \1
  upload: (.*)\.html

您还将希望拥有您的PHP脚本 echo print 会导致响应而不是 return ,实际上并不会将任何内容返回到浏览器进行显示.

You'll also want to have your PHP script echo or print results in the response rather than return, which doesn't actually return anything to the browser for display.

这篇关于App Engine YAML文件未运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆