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