Reputation: 47
import webapp2
form="""
<form method="post">
<input type="" name="day">
<input type="" name="month">
<input type="" name="year">
<input type="submit" name="">
</form>
"""
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.out.write(form)
def post(self):
self.response.out.write("thank")
app = webapp2.WSGIApplication([('/', MainPage),], debug=True)
this code responds with
405 Method Not Allowed
The method POST is not allowed for this resource.
Upvotes: 1
Views: 382
Reputation: 619
I encountered the same problem. The editor you are using has a wrong configuration for "indentation", which is crucial for python's interpreter to interpret the code correctly.
Try re-write this program with Python IDE.
Upvotes: 2
Reputation: 26647
It's something with your configuration. I tested your code almost identical to what you posted and it responds correctly (with google appengine).
class MainPage(webapp2.RequestHandler):
form = """
<form method="post">
<input type="" name="day">
<input type="" name="month">
<input type="" name="year">
<input type="submit" name="">
</form>
"""
def get(self):
self.response.out.write(self.form)
def post(self):
self.response.out.write("thank")
app = microwsgi.MicroWSGIApplication([
('/MainPage', MainPage)...
Upvotes: 0