简体   繁体   中英

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?

It looks like there are a few mistakes in your code:

  • The indentation in your post() method is incorrect. The if-else statement needs to be further indented.
  • I don't see a definition of the function valid_month

Your log should show you these and perhaps other errors and give you the info you need to fix them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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