Intro to Backend >> Forms and Inputs >> Responding Based on Verification
How and where to include the new functions we just made, into our main.py file:
You will need to copy the list of months, the month function, the day function, and the year function, in that order, and paste them right after
and before class MainHandler(webapp2.RequestHandler): within main.py.
Here is what it should look like to run:
# Copyright 2007 Google Inc.
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an “AS IS” BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
what is your birthday?
months = [‘January’,
month_abbs = dict((m[:3].lower(), m) for m in months)
short_month = month[:3].lower()
if day and day.isdigit():
day = int(day)
if day > 0 and day < 32: return day
if year and year.isdigit():
year = int(year)
if year > 1900 and year < 2020:
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(“Thanks! That’s a totally valid day!”)
app= webapp2.WSGIApplication([(‘/’, MainHandler)], debug=True)