【问题标题】:GAE creating a new project?GAE 创建一个新项目?
【发布时间】:2013-11-12 18:00:33
【问题描述】:

我一直在研究 GAE - 尝试创建一个新项目:命令出错

abid@abid-webdev:~/Documents/GAE_projects$ python google_appengine/dev_appserver.py exe1.py/

错误

INFO 2013-10-29 08:27:57,104 module.py:608] 默认值:“GET / HTTP/1.1”500 - 错误 2013-10-29 08:29:43,171 wsgi.py:262] 回溯(最近一次通话最后): 文件“/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py”,第 239 行,在 Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) _LoadHandler 中的文件“/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py”,第 298 行 处理程序,路径,错误 = LoadObject(self._handler) LoadObject 中的文件“/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py”,第 84 行 obj = 导入(路径[0]) ImportError:没有名为 helloworld 的模块 INFO 2013-10-29 08:29:43,191 module.py:608] 默认值:“GET / HTTP/1.1”500 - 错误 2013-10-29 08:29:51,775 wsgi.py:262] 回溯(最近一次通话最后): 文件“/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py”,第 239 行,在 Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) _LoadHandler 中的文件“/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py”,第 298 行 处理程序,路径,错误 = LoadObject(self._handler) LoadObject 中的文件“/home/abid/Documents/GAE_projects/google_appengine/google/appengine/runtime/wsgi.py”,第 84 行 obj = 导入(路径[0]) ImportError: 没有名为 helloworld 的模块

1) ImportError: No module named helloworld -> 我注意到了这个错误

  • 目前正在处理这个项目exercise1,从之前的项目helloworld/复制了app.yaml文件

  • 查看app.yaml,内容如下:

应用程序:您的应用程序 ID 版本:1 运行时:python27 api_version: 1 线程安全:真

处理程序: - 网址:/.*

脚本:helloworld.application>

2) on google URL -> 对路径匹配正则表达式 /.*(所有 URL)的 URL 的每个请求都应由 helloworld 模块中的应用程序对象处理。

3) 我的目录结构

abid@abid-webdev:~/Documents/GAE_projects$ ls

运动1
你好世界
google_appengine

问题:

如何修改我的 app.yaml 以与我的其他项目一起使用,例如 练习1?

感谢大家的帮助。

【问题讨论】:

标签: google-app-engine


【解决方案1】:

让我们从头开始!

对于您的新项目,您需要在练习 1 目录中具有以下结构:

Directory: exercise1
  File: app.yaml
  File: exercise1.py

在 app.yaml 中你需要这样的东西:

application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: exercise1.application

“script: exercise1.application”这一行告诉它要使用哪个文件(在本例中为 exercise1.py)以及要使用的 WSGI 处理程序实例(在本例中为 application)

在 exercise1.py 中你需要这样的东西:

import webapp2


class HomePage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Hey Y'all!')

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

在这里您可以看到我们在 app.yaml 中提到的 应用程序

一旦你有了这个基本结构,你就需要启动开发应用服务器。您在问题中的做法不正确:

您需要使用目录“exercise1”运行 dev_appserver,而不是 python 文件。

假设 Google App Engine sdk 仍位于“~/Documents/GAE_projects/google_appengine”,从exercise1 目录运行以下命令:

python ~/Documents/GAE_projects/google_appengine/dev_appserver.py ./

这将启动 dev_appserver.py 脚本,告诉它使用当前目录(这就是“./”的意思)。

如果你遵循这个,那么你应该开始并滚动!

【讨论】:

  • -> 这实际上是.. 感谢您的输入,之前来自URL 的建议也很有用。我如何标记这个已解决?
  • 我的答案旁边应该是一个灰色的勾号,如果你点击它应该变成绿色,这将选择这个作为接受的答案。 :)
猜你喜欢
  • 2020-12-03
  • 2020-11-12
  • 1970-01-01
  • 2016-11-02
  • 2023-03-04
  • 2018-08-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多