2013-10-16 172 views
0

我正在执行以下代码。网页不重新加载

import webapp2 

form=""" 
    <form method = "post"> 
    What is your birthday? 
    <p> 
    <label> 
    Day 
    <input type = "text" name = "day"> 
    Month 
    <input type = "text" name = "month"> 
    Year 
    <input type = "text" name = "year"> 
    </p> 
    <input type = "submit"> 
    </form> 
    """ 

class MainHandler(webapp2.RequestHandler): 
    def get(self): 
    self.response.out.write(form) 

    def post(self): 
    self.response.out.write(form) 


app = webapp2.WSGIApplication([ 
    ('/', MainHandler) 
], debug=True) 

当我尝试打开该网页本地主机:8080,我看不到任何东西。该页面为空。

+0

服务网页是什么? [本页](http://webapp-improved.appspot.com/tutorials/quickstart.html)表明Google App引擎或本地设置都应该这样做。你有没有设置它们? –

回答

0

我不熟悉而webapp2但:

快速浏览到tutorials我看到后把它们写:

self.response.write(...) instead of self.response.out.write() 

你的代码是不正确的缩进,你应该有:

def get(self): 
     self.response.write(form) 

字符串“form”似乎不是一个有效的html页面

也许你可以试试

<!DOCTYPE html> 
<html> 
<head> 
<title>Whatever</title> 
</head> 
<body> 
    <form method = "post"> 
    What is your birthday? 
    <p> 
    <label> 
    Day 
    <input type = "text" name = "day"> 
    Month 
    <input type = "text" name = "month"> 
    Year 
    <input type = "text" name = "year"> 
    </p> 
    <input type = "submit"> 
    </form> 
</body> 
</html>