简体   繁体   English

Google App Engine Python 2.7启动器-Localhost显示空白页

[英]Google App Engine Python 2.7 Launcher - Localhost shows a blank page

I was trying to complete an online tutorial and got stuck on this part. 我试图完成在线教程,却陷入了这一部分。 The app is running and the port is entered correctly. 应用正在运行,并且端口输入正确。 Instead of the form, the browser displays 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)

Have you looked at the log generated by the GoogleAppEngineLauncher? 您是否看过GoogleAppEngineLauncher生成的日志?

It looks like there are a few mistakes in your code: 您的代码中似乎有一些错误:

  • The indentation in your post() method is incorrect. 您的post()方法中的缩进不正确。 The if-else statement needs to be further indented. if-else语句需要进一步缩进。
  • I don't see a definition of the function valid_month 我看不到valid_month函数的定义

Your log should show you these and perhaps other errors and give you the info you need to fix them. 您的日志应显示这些错误以及其他错误,并为您提供修复它们所需的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM