python - GAE Python 应用程序无法启动 "No URLMap entries found in application configuration"

标签 python google-app-engine

我正在遵循一本名为“Google App Engine With Python”的书中的第一个练习,并创建了一个名为 clock 的目录,其中包含两个名为 app.yaml 的文件和 main.py ,我已经从书中准确复制了代码,但我无法使用 dev_appserver.py 启动它。我认为这可能与 app.yaml 中的 URL 处理程序有关,但正如我所说,我已经完全复制了它,所以不确定问题是什么。当我在终端中运行 dev_appserver.py Clock 时,会发生这种情况:

    Traceback (most recent call last):
  File "/Users/James/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 103, in <module>
    _run_file(__file__, globals())
  File "/Users/James/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 97, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/Users/James/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 346, in <module>
    main()
  File "/Users/James/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 334, in main
    dev_server.start(options)
  File "/Users/James/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 94, in start
    env_variables=parsed_env_variables)
  File "/Users/James/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 929, in __init__
    env_variables)
  File "/Users/James/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 132, in __init__
    self._config_path)
  File "/Users/James/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 499, in _parse_configuration
    config, files = appinfo_includes.ParseAndReturnIncludePaths(f)
  File "/Users/James/google-cloud-sdk/platform/google_appengine/google/appengine/api/appinfo_includes.py", line 93, in ParseAndReturnIncludePaths
    'No URLMap entries found in application configuration')
google.appengine.api.appinfo_errors.MissingURLMapping: No URLMap entries found in application configuration

这是我的 app.yaml 代码:

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

handlers:
- url: .*

script: main.application

libraries:
- name: webapp2
  version: "2.5.2"

这是我的 main.py 代码

import datetime
import webapp2

class MainPage(webapp2.RequestHandler):
  def get(self):
    message = '<p>The time is: %s</p>' % datetime.datetime.now()
    self.response.out.write(message)

application = webapp2.WSGIApplication([('/', MainPage)], debug=True)

有人可以帮忙吗?

最佳答案

app.yaml 中的 handlers 部分格式不正确。 script: 部分需要在 url 模式下缩进,如下所示:

handlers:
- url: .*
  script: main.application

关于python - GAE Python 应用程序无法启动 "No URLMap entries found in application configuration",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46617177/

相关文章:

python - Python制作命名空间包的方法

python - Py2app:不允许操作

google-app-engine - 如何解决主要的应用引擎问题?

python - Google App Engine 适合我吗?

python - 如何使用 Python Popen 处理多个参数?

python - 值错误 : I/O operation on closed (csv) file

python - 从新闻网站中提取用户评论

google-app-engine - 多个网站托管在一个 Google Apps 帐户上

python - “WSGIRequest”对象在 Google App Engine 中没有属性 'user'

wordpress - 如何从指向由 google app engine 托管的应用程序的域托管 wordpress 博客?