我一直在嘗試使用GAE/Python從「使用Google App Engine」一書中獲取示例。我有幾個問題工作正常,直到我修改了主要的python文件,當我開始變得空白的瀏覽器頁面。谷歌應用引擎 - 瀏覽器上的空白頁面,但沒有錯誤
登錄控制檯
INFO 2013-12-13 21:17:34,568 module.py:617] default: "GET/HTTP/1.1" 200 -
INFO 2013-12-13 21:17:34,737 module.py:617] default: "GET /favicon.ico HTTP/1.1" 200 -
index.py
我不知道我錯過了什麼,但這裏的Python代碼。
import os
import logging
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
def doRender(handler, tname='index.html', values={}):
#Check if the template file tname exists
temp = os.path.join(os.path.dirname(__file__),
'template/' + tname)
if not os.path.isfile(temp):
return False
# If template file exisis, make a copy and add the path
newval = dict(values)
newval['path'] = handler.request.path
outstr = template.render(temp, newval)
handler.response.out.write(str(outstr))
return True
class LoginHandler(webapp.RequestHandler):
def get(self):
doRender(self, 'loginscreen.html')
def post(self):
acct = self.request.get('account')
pw = self.request.get('password')
logging.info('Checking account = '+acct+' pw='+pw)
if pw == '' or acct == '':
doRender(self, 'loginscreen.html', {'error': 'Please specify Account and Password'})
elif pw == 'secret':
doRender(self, 'loggedin.html', {})
else:
doRender(self, 'loginscreen.html', {'error': 'Incorrect password'})
class MainHandler(webapp.RequestHandler):
def get(self):
if doRender(self, self.request.path):
return
doRender(self, 'index.html')
def main():
application = webapp.WSGIApplication([
('/login', LoginHandler),
('/.*', MainHandler)],
debug=True)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()
正如您所看到的,控制檯報告沒有錯誤,但是在瀏覽器中查看時,空白屏幕會回顧我。我錯過了什麼嗎?
什麼是你的index.html的內容? – brian