谷歌引擎(进程退出代码1)

时间:2013-10-26 04:54:44

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

我正在尝试在谷歌应用引擎中运行以下代码。

//app.yaml
      application: engineapp
      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"
       - name: jinja2
       version: "2.7"
       - name: markupsafe
      version: "0.18"


       #main.py

       import datetime
       import jinja2
       import os
       import webapp2
       from google.appengine.api import users
       template_env = jinja2.Environment(
       loader=jinja2.FileSystemLoader(os.getcwd()))
       class MainPage(webapp2.RequestHandler):
      def get(self):
      current_time = datetime.datetime.now()
      user = users.get_current_user()
      login_url = users.create_login_url(self.request.path)
      logout_url = users.create_logout_url(self.request.path)
      template = template_env.get_template('home.html')
      context = {
     'current_time': current_time,
      'user': user,
      'login_url': login_url,
     'logout_url': logout_url,
       }
        self.response.out.write(template.render(context))
        application = webapp2.WSGIApplication([('/', MainPage)],
      debug=True)


       #home.html
      <html>
      <head>
      <title>The Time Is...</title>
      </head>
      <body>
      {% if user %}
      <p>
      Welcome, {{ user.email() }}!
      You can <a href="{{ logout_url }}">sign out</a>.
      </p>
      {% else %}
      <p>
      Welcome!
      <a href="{{ login_url }}">Sign in or register</a> to customize.
      </p>
      {% endif %}
      <p>The time is: {{ current_time }}</p>
      </body>
      </html>

但我收到了以下错误

  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: Missing required value 'version'.
  in "D:\codings\appEngen\engineapp\app.yaml", line 19, column 1
2013-10-25 23:47:59 (Process exited with code 1)

请帮帮我,谢谢你的时间。

1 个答案:

答案 0 :(得分:2)

问题出在你的app.yaml文件中:它没有正确缩进。特别是markupsafe版本声明。试试这个:

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

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"
- name: jinja2
  version: "2.7"
- name: markupsafe
  version: "0.18"