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

标签 python google-app-engine python-2.7

我有downaloded and installed Python 2.7.6在我的 Windows 中,我还安装了最新版本的 GAE SDK也适用于 Windows。

我的 GAE 上有以下配置: GAE_configs

我正在运行一个包含以下文件的 Hello World 项目:

主要.py

import webapp2

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

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

应用.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. 我通过转到文件 -> 新应用程序创建了这个项目,但显然我自动生成的 app.yaml 文件不正确。我究竟做错了什么?
  2. 我曾尝试先使用 Python 3.3,但没有成功。 GAE 仅适用于 Python 2.7,对吧?我做的每件事都正确,对吗?
  3. 当我单击“浏览”按钮时,我收到一条错误消息,指出未指定浏览器。我该如何解决?

如有可能,感谢您的帮助:S

最佳答案

根据不匹配的正则表达式,应用名称需要小写:

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

关于python - 无法在 Google App Engine Windows 上运行 Hello World,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20378641/

相关文章:

Django 和应用引擎

python - 在 Python 中压缩嵌套列表

Python:从格式化字符串中提取字段

python - 钩子(Hook)python模块函数

python - 数据存储客户端 query.fetch() 抛出错误

android - 我应该在 Android-AppEngine 系统的 Android App 部分使用 Objectify Annotated Objects 吗?

python - 如果在 for 循环中,如何在单行中使用 "continue"

转换后的字符串的 Python TypeError 为 None

python-2.7 - 为什么随机种子不能使结果在 Python 中保持不变

python - Durationfield django