GAEを使用しているWebアプリケーションでアップロード機能を実装する時点で固まっています。/signupページに投稿すると、/ upload_fileページにリダイレクトされますが、エラーメッセージ405が表示されます。許可されません。アップロードフォームが表示されることを期待していました。Google App Engine:405メソッドこのリソースにはGETが許可されていません
(からいくつかのリファレンスを手に入れた:https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/blobstore/main.py)
任意の助けに感謝!メインのPythonスクリプト内のコードの
パート:
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)
ありがとうございますが、おそらくあまり混乱URLパスを考え出す必要があるような
お役立ち情報bolbstoreのサンプルコードは機能しますか?それ以外の場合は、更新する必要があります。 :) –
あなたはどんな例を参照していますか? –
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/blobstore/main.py –