[英]Google App Engine Python 2.7 Launcher - Localhost shows a blank page
我試圖完成在線教程,卻陷入了這一部分。 應用正在運行,並且端口輸入正確。 瀏覽器將顯示空白頁面,而不是表單。
import webapp2
form="""
<form method="post">
What is your birthday?
<br>
<br>
<label> Month
<input type="text" name="month">
</label>
<label> Day
<input type="text" name="day">
</label>
<label> Year
<input type="text" name="year">
</label>
<br>
<br>
<input type="submit">
</form>
"""
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.write(form)
def post(self):
user_month = valid_month(self.request.get('month'))
user_day = valid_day(self.request.get('day'))
user_year = valid_year(self.request.get('year'))
if not (user_month and user_day and user_year):
self.response.out.write(form)
else:
self.response.out.write("Thanks! That's a totally valid day!")
app = webapp2.WSGIApplication([
('/', MainPage)
], debug=True)
您是否看過GoogleAppEngineLauncher生成的日志?
您的代碼中似乎有一些錯誤:
post()
方法中的縮進不正確。 if-else語句需要進一步縮進。 valid_month
函數的定義 您的日志應顯示這些錯誤以及其他錯誤,並為您提供修復它們所需的信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.