无法在Google App Engine Windows上运行Hello World

时间:2013-12-04 14:58:19

标签: python google-app-engine python-2.7

我的Windows中有downaloded and installed Python 2.7.6,我也为Windows安装了最新版本的GAE SDK

我的GAE上有以下配置: GAE_configs

我正在使用以下文件运行Hello World项目:

Main.py

import webapp2

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.write('Hello world!')

app = webapp2.WSGIApplication([('/', MainHandler)], debug=True)

的app.yaml

application: HelloWorld
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"

然而,当我点击运行按钮时,为了让他投票,我在LOG输出中出现以下错误:

2013-12-04 14:51:49 Running command: "['C:\\Python27\\pythonw.exe', 'C:\\Program Files (x86)\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=8080', '--admin_port=8000', 'D:\\Users\\pedro\\Desktop\\HelloWorld']"
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 197, in <module>
    _run_file(__file__, globals())
  File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 193, in _run_file
    execfile(script_path, globals_)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 872, in <module>
    main()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 865, in main
    dev_server.start(options)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 657, in start
    options.yaml_files)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\application_configuration.py", line 549, in __init__
    module_configuration = ModuleConfiguration(yaml_path)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\application_configuration.py", line 82, in __init__
    self._yaml_path)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\application_configuration.py", line 266, in _parse_configuration
    return appinfo_includes.ParseAndReturnIncludePaths(f)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\appinfo_includes.py", line 63, in ParseAndReturnIncludePaths
    appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\appinfo.py", line 1756, in LoadSingleAppInfo
    listener.Parse(app_info)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\yaml_listener.py", line 226, in Parse
    self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\yaml_listener.py", line 177, in _HandleEvents
    raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: Unable to assign value 'HelloWorld' to attribute 'application':
Value 'HelloWorld' for application does not match expression '^(?:(?:[a-z\d\-]{1,100}\~)?(?:(?!\-)[a-z\d\-\.]{1,100}:)?(?!-)[a-z\d\-]{0,99}[a-z\d])$'
  in "D:\Users\pedro\Desktop\HelloWorld\app.yaml", line 1, column 14
2013-12-04 14:51:50 (Process exited with code 1)

因此,我有以下任务:

  1. 我通过转到文件创建了这个项目 - &gt;新的应用程序,但显然我的自动生成的app.yaml文件不正确。我究竟做错了什么?
  2. 我首先尝试使用Python 3.3,但它无法正常工作。 GAE只适用于Python 2.7吗?我正确地做好每一件事吗?
  3. 当我单击“浏览”按钮时,我收到错误消息,指出没有指定浏览器。我该如何解决这个问题?
  4. 如果可能的话,感谢您的帮助:S

2 个答案:

答案 0 :(得分:12)

根据不匹配的正则表达式,应用名称必须为小写:

>>> regex = r'^(?:(?:[a-z\d\-]{1,100}\~)?(?:(?!\-)[a-z\d\-\.]{1,100}:)?(?!-)[a-z\d\-]{0,99}[a-z\d])$'
>>> print(re.match(regex, 'HelloWorld'))
None
>>> print(re.match(regex, 'helloworld'))
<_sre.SRE_Match object at 0x13ac308>

答案 1 :(得分:1)

您的应用程序标识符('HelloWorld')无效。您应该根据GAE doc使用您在管理控制台中创建的那个。

在appspot.com中部署时,该ID将是GAE应用程序的子域。这就是应用ID与正则表达式r'^(?:(?:[a-z\d\-]{1,100}\~)?(?:(?!\-)[a-z\d\-\.]{1,100}:)?(?!-)[a-z\d\-]{0,99}[a-z\d])$'匹配的原因。