Upload HTML file to Google App Engine - getting 405

I am trying to make a simple echo application using Python. I want to send a file with a POST form and repeat it (HTML file).

Here is the section of handlersused NML:

handlers:
- url: /statics
  static_dir: statics

- url: .*
  script: main.py

This is basically a welcome example in main.py, and I added a directory to host my static html form file. Here's the HTML in statics/test.html:

<form action="/" enctype="multipart/form-data" method="post">
    <input type="file" name="bookmarks_file">
    <input type="submit" value="Upload">
</form>

The handler is as follows:

#!/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()

However, when I send the file, I get an error 405. Why?

+3
source share
1 answer

POST, post() get(). def get(self): def post(self): HTTP 405.

+9

Source: https://habr.com/ru/post/1733799/


All Articles