使用Google App Engine Launcher无法部署网站

0 投票
1 回答
669 浏览
提问于 2025-04-18 06:28

我正在创建一个网站,想把它放到网上。但是我用谷歌应用引擎启动器部署的时候,不管试多少次都没成功。

app.yaml 文件:

application: GameDroidWeb
version: 1
runtime: python
api_version: 1

handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css))
  static_files: \1
  upload: (.*\.(gif|png|jpg|ico|js|css))

- url: /robots.txt
  static_files: robots.txt
  upload: robots.txt 

- url: .*
  script: main.py

main.py 文件:

# Copyright 2012 Digital Inspiration
# http://www.labnol.org/

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 ()

部署控制台日志:

2014-05-13 22:53:29 Running command: "['C:\\Python33\\pythonw.exe', '-u', 'C:\\Program Files (x86)\\Google\\google_appengine\\appcfg.py', '--no_cookies', u'--email=TheAddictedGamerOfficial@gmail.com', '--passin', 'update', 'C:\\Users\\User\\Desktop\\WEBSITE TEST']"
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 126, in <module>
    run_file(__file__, globals())
  File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 122, in run_file
    execfile(_PATHS.script_file(script_name), globals_)
NameError: global name 'execfile' is not defined
2014-05-13 22:53:29 (Process exited with code 1)

You can close this window now.

有没有人知道怎么解决这个问题?我试过卸载再重新安装,但也没用。任何帮助都非常感谢。谢谢大家!

1 个回答

2

你现在使用的是Python 3,但你需要的是Python 2.7。

(这个Python开发工具包不支持Python 3。) 你可以从这里找到更多信息。

撰写回答