i have been using udacity.com learn program ran problem code(python). application post allow put down day born , when push submit it's post "thanks that's totally valid day!". it's not doing it. application restarts again. can tell me why statement not working , how fix it.
import webapp2 form=""" <form> birthday? <br> <label>month<input type="type" name="month"></label> <label>day<input type="type" name="day"></label> <label>year<input type="type" name="year"></label> <div style="color: red">%(error)s</div> <br> <br> <input type="submit"> </form> """ class mainpage(webapp2.requesthandler): def write_form(self, error=""): self.response.out.write(form % {"error": error} ) def get(self): self.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 , user_month , user_year): self.write_form("that doesn't valid me, friend.") else: self.response.out.write("thanks! that's totally valid day!") app = webapp2.wsgiapplication([('/',mainpage)], debug=true)
that fragment has syntax error. if you're watching terminal/console, you'll notice python complain else (which missing trailing :). watching console, , understanding it's saying, key if want make progress.
with fixed, you'll see form. then, when trying posting, you'll "405 method not allowed" because post method over-indented.
Comments
Post a Comment