cra*_*ice 3 html python google-app-engine
我是一个蟒蛇新手,我正在尝试逐步建立一个应用程序,我在课堂上已经教过了,但我得到了"405 Method Not Allowed"错误.
教授在这里做了什么:

我在这做了什么:

有人能指出我在下面的代码中是什么导致此错误"405 Method Not Allowed"?我看不出我做了什么和教授教的内容之间的区别.缩进也可以(这里是main.py文件https://docs.google.com/open?id=0B8TXLR_e14aCVDFfdlpYSU9DNDg).
在此先感谢您的帮助!
这是我的代码:
form= """
<html>
<head>
<title>Unit 2 Rot 13</title>
</head>
<body>
<h2>Enter some text to ROT13:</h2>
<form method="post" action="/rot13">
<textarea name="text"
style="height: 100px; width: 400px;"></textarea>
<br>
<input type="submit">
</form>
</body>
</html> """
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write(form)
class Rot13Handler(webapp2.RequestHandler):
def post(self):
text = self.request.get("text")
self.response.out.write(text)
app = webapp2.WSGIApplication([('/', MainHandler), ('/rot13', Rot13Handler)],
debug=True)
Run Code Online (Sandbox Code Playgroud)
小智 9
我只是在Udacity的在线课程后尝试Python,并遇到类似的问题,AppEngine无法找到post方法.
最后,事实证明,根本原因是INDENTION.
我使用Notepad ++作为小项目的编辑器,它只是无法工作,继续抛出405错误.然后我将代码复制并粘贴到安装了Python插件的Netbean IDE中,IDE显示错误的缩进使得POST方法成为GET方法的内部方法,这在Notepad ++中找不到,尽管它看起来像是缩进的处理得好.
| 归档时间: |
|
| 查看次数: |
11479 次 |
| 最近记录: |