def post(self): logging.info("hi") upload_files = self.get_uploads('file') # 'file' is file upload field in the form blob_info = upload_files[0] userID = users.get_current_user().user_id() image = Image(parent = ndb.Key('image', userID), blobKey=blob_info.key(), urlString = get_serving_url(blob_info.key(), size=None, crop=False, secure_url=None)) image.put() self.redirect('/my-dashboard')
def fill_dragons(image: Image, indices): image = image.copy() for x, y in indices: for i in range(len(DRAGON)): for j in range(len(DRAGON[i])): if not image.in_bounds(x + i, y + j): print(f"error: x={x}, y={y}, i: {i}, j: {j}") raise Exception("Unexpected out of bounds while filling") if DRAGON[i][j] == "#": if image.get(x + i, y + j) not in ("#", "O"): print(f"error: x={x}, y={y}, i: {i}, j: {j}") raise Exception("Unexpected mismatch while filling") image.put(x+i, y+j, "O") return image