在应用程序中部署的网站未显示

时间:2014-12-08 19:51:31

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

您好:所以当我使用启动器运行它时,我正在尝试将网站部署到appEngine,日志没有任何错误,但是当我转到本地主机时,页面是空白的。我之前在python2.5中运行这个网站没有任何问题,你能看到任何错误吗?

的app.yaml

application: myappname
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /(.*\.(gif|png|json|jpg|ico|js|css))
  static_files: \1
  upload: (.*\.(gif|png|json|jpg|ico|js|css))

- url: .*
  script: main.app

- url: /(.*\.json)
  mime_type: application/json
  static_files: static/\1
  upload: static/(.*\.json)

libraries:
- name: webapp2
  version: latest

main.py

import webapp2
import os
from google.appengine.ext.webapp2 import util
from google.appengine.ext.webapp2 import template

class MainPage(webapp2.RequestHandler):
  def get (self, q):
    if q is None:
      q = 'index.html'
    path = os.path.join (os.path.dirname (__file__), q)
    self.response.headers ['Content-Type'] = 'text/html'
    self.response.out.write (template.render (path, {}))

app = webapp2.WSGIApplication([('/(.*html)?', MainPage)])

1 个答案:

答案 0 :(得分:1)

将第3行和第4行(可以将它们组合)更改为:

from google.appengine.ext.webapp import util, template

webapp,而不是webapp2