3
我正在尝试使用Python做一个简单的echo应用程序。我想用POST表单提交一个文件并将其回显(HTML文件)。将HTML文件上传到Google App Engine - 获得405
这里是YAML的handlers
部分我使用:
handlers:
- url: /statics
static_dir: statics
- url: .*
script: main.py
它基本上是在main.py
hello world示例,我加一个目录来我的静态html格式文件。下面是statics/test.html
的HTML:
<form action="/" enctype="multipart/form-data" method="post">
<input type="file" name="bookmarks_file">
<input type="submit" value="Upload">
</form>
处理程序是这样的:
#!/usr/bin/env python
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
class MainHandler(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write(self.request.get('bookmarks_file'))
def main():
application = webapp.WSGIApplication([('/', MainHandler)],
debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()
但是,发布文件时,我得到一个错误405。怎么来的?
这是一个模型答案。 – 2010-02-22 02:26:18
[facepalm] 为我在晚上尝试新SDK提供了正确的方法。谢谢。 – 2010-02-22 06:13:21