&引用;405“不允许使用方法”;在Python webapp2中 导入webapp2 form=”“” """ 类主页(webapp2.RequestHandler): def get(自我): 自我.回应.输出.写入(表格) def post(自我): 自我。回应。输出。写下(“谢谢”) app=webapp2.WSGIApplication([('/',主页),],debug=True)

&引用;405“不允许使用方法”;在Python webapp2中 导入webapp2 form=”“” """ 类主页(webapp2.RequestHandler): def get(自我): 自我.回应.输出.写入(表格) def post(自我): 自我。回应。输出。写下(“谢谢”) app=webapp2.WSGIApplication([('/',主页),],debug=True),python,webapp2,Python,Webapp2,此代码以 405方法不允许 此资源不允许使用方法POST 这与您的配置有关。我对你的代码进行了测试,测试结果与你发布的代码几乎相同,并且它的响应正确(使用谷歌appengine) 类主页(webapp2.RequestHandler): form=”“” """ def get(自我): self.response.out.write(self.form) def post(自我): 自我。回应。输出。写下(“谢谢”) app=microwsgi.MicroWSGIApplication([ (

此代码以

405方法不允许

此资源不允许使用方法POST


这与您的配置有关。我对你的代码进行了测试,测试结果与你发布的代码几乎相同,并且它的响应正确(使用谷歌appengine)

类主页(webapp2.RequestHandler):
form=”“”
"""
def get(自我):
self.response.out.write(self.form)
def post(自我):
自我。回应。输出。写下(“谢谢”)
app=microwsgi.MicroWSGIApplication([
(“/MainPage”,MainPage)。。。

我遇到了同样的问题。您使用的编辑器对“缩进”的配置错误,这对于python解释器正确解释代码至关重要


请尝试使用Python IDE重新编写此程序。

欢迎使用堆栈溢出。请回答您的问题并修复所发布代码的缩进,以便我们可以查看类的一部分和不部分。
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)
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)...