我有一些問題的處理方式,並在升級之後的返樸歸真,我不能讓小例子的工作:什麼導致列表索引超出範圍?
class PhotoUploadFormHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write('<html><body>')
self.response.out.write('<form action="%s" method="POST" enctype="multipart/form-data">' % blobstore.create_upload_url('/upload_photo'))
self.response.out.write('''Upload File: <input type="file" name="file"><br> <input type="submit"
name="submit" value="Submit"> </form></body></html>''')
class PhotoUploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
try:
upload = self.get_uploads()[0]
user_photo = UserPhoto(user=users.get_current_user(),
blob_key=upload.key())
db.put(user_photo)
self.redirect('/view_photo/%s' % upload.key())
except Exception, ex:
self.response.out.write(str(ex))
app = webapp2.WSGIApplication([
('/upload_form', PhotoUploadFormHandler),
('/upload_photo', PhotoUploadHandler),
以上的回報異常在訪問上傳的文件:
列表索引超出範圍
爲什麼? 感謝您的幫助。
請包括完整的堆棧跟蹤,而不是編輯出所有有用的細節。 –