作为免责声明,我是应用程序开发的新手。
因此,我一直在使用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] 删除。
我来说两句