I'm stuck at a point to implement the upload function in my web application using GAE. After submitting at /signup page, it redirects to /upload_file page, while it prompts the error 405 Method Get not allowed, and I was expecting to see the upload form.
(Got some Reference from: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/blobstore/main.py)
Appreciate any help!
Part of the code in a main python script:
class FileUploadFormHandler(BaseHandler):
# BaseHandler is a subclass of webapp2.RequestHandler.
def get(self):
# create an upload URL for the form that the user will fill out
upload_url = blobstore.create_upload_url('/upload_file')
self.render('upload-file.html', upload_url = upload_url)
class FileUploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
upload = self.get_uploads('file')[0] ## 'file' is a var in the upload-file.html
blob_key = upload.key()
blob_reader = blobstore.BlobReader(blob_key) # instantiate a BlobReader for a given BlobStore value.
locations = parsefile(blob_reader)
img_url = generate_url(locations=locations)
self.redirect('/view_map/%s' % img_url)
app = webapp2.WSGIApplication([('/', Home),
('/signup', Register),
('/login', Login),
('/logout', Logout),
('/upload_file', FileUploadHandler),
('/view_map/([^/]+)?', ViewMap)
],
debug=True)