我可以在适用于Python的Google App Engine上运行PHP文件吗?

jpdstan

作为免责声明,我是应用程序开发的新手。

因此,我一直在使用Google App Engine和Python Runtime Environment在该网站上工作。当我用HTML创建简单表单并决定使用PHP存储数据时,出现了问题。当我的应用程序在Python中运行时,我可以使用PHP脚本吗?

我还注意到GAE现在有一个PHP运行时环境,所以我应该改用它吗?我之所以只使用Python,是因为它一开始就很容易使用,而且我认为我不需要PHP。

这是我的main.py样子,如果很重要:

import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template

class MainHandler(webapp.RequestHandler):
  def get (self, q):
    if q is None:
      q = 'index.html'

    path = os.path.join (os.path.dirname (__file__), q)
    self.response.headers ['Content-Type'] = 'text/html'
    self.response.out.write (template.render (path, {}))

def main ():
  application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
  util.run_wsgi_app (application)

if __name__ == '__main__':
  main ()
丹·桑德森

不,您将无法在Python运行时环境中运行PHP脚本。如果您的应用程序更容易用PHP编写,则可以使用PHP运行时环境。

在中app.yaml,设置runtime: php并创建handlers:,其中script:值是一个PHP脚本:

applciation: helloworld
version: 1
runtime: php
api_version: 1

handlers:
- url: /.*
  script: helloworld.php

然后helloworld.php可以是一个PHP脚本,例如:

<?php
  echo 'Hello, world!';
?>

请注意,您可以对Python和PHP使用相同的SDK。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

适用于Google App Engine Python的OAuth

如何在我的脚本/自动加载中包括适用于PHP的Google App Engine?

ImportError:没有名为_ctypes的模块在Windows上运行适用于Google App Engine的Python Flask教程

适用于Google App Engine的Laravel Mod无法在Windows上运行

Google SQL 不适用于 Google App Engine

适用于python2.7 Google App Engine的Cloud Tasks API

适用于Google App Engine的BigQuery cron作业凭据

适用于自己的Python应用程序的Google App-Engine运行setup.py安装

使用Python在App Engine上读取文件吗?

.jsp文件不适用于Google App Engine留言簿教程

我可以在Google App Engine上使用CGo吗?

我可以在Google App Engine上使用HikariCP吗

如何在 Google Cloud App Engine 上运行 PHP 服务

如何定义分割给定网址的方法(在适用于Google App Engine的python webapp2中)

无法使Google App Engine OAuth2-sample(适用于Python)正常工作-400错误:redirect_uri_mismatch

适用于多种环境的Google Cloud App Engine app.yaml

适用于Google App Engine和laravel的app.yaml中的处理程序失效

运行适用于PHP的开发网络服务器Google App引擎

适用于Web服务器或App Engine的Google Compute Engine

适用于 Microsoft Teams 的 Azure Bot App Reg 可以使用单租户吗?

适用于Google App Engine标准环境的max_num_instances

Flask vs webapp2(适用于Google App Engine)

Spring Boot安全性不适用于Google App Engine

为什么 Google App Engine flex 构建步骤失败,而标准适用于相同的代码?

适用于Google App Engine的Secured Cron Job无法启动(Node js)

Google App Engine 托管安全仅适用于“www”别名

我可以使用python开发适用于ubuntu touch的应用程序吗?

Google Play上的Android App不兼容,仅适用于某些设备

使Django 1.7在Google App Engine上运行