

def post(self):
    'Handles the post request with the sudoku image to solve.\n        Accepts binary (as from <input type="file">) as default, and looks for an image\n        file at a specified URL if the binary input is not given.\n        Launches a task queue task, run on a VM backend, to solve the given puzzle.\n        Returns a JSON message to the client, which includes a URL that will contain\n        the result.\n        '
    filename = utils.create_fname('jpg')
    solved_url = (self.api_url + filename)
    image_data = self.request.get('sudoku')
    image_url = ''
    if image_data:
        image_data = decode_if_needed(image_data)
        gcs_file = utils.create_png_file(image_data)
        image_url = (self.api_url + gcs_file)
    else:
        logging.info('did not get image data from form submit')
        image_url = self.request.get('sudoku_url')
    if (not image_url):
        logging.warn('could not generate image url')
        resp = self.generate_error_response(filename, solved_url)
        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(filename)
        return
    logging.info('using image url: %s', image_url)
    try:
        task = taskqueue.Task(url='/solve_async', method='POST', params={
            'image_url': image_url,
            'filename': filename,
        })
        taskqueue.Queue().add(task)
        resp = {
            'status': 'OK',
            'solved_url': solved_url,
        }
        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps(resp))
    except (taskqueue.UnknownQueueError, taskqueue.TransientError):
        logging.exception('issue adding task to queue')
        resp = self.generate_error_response(filename, solved_url)
        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(resp)

dataset/ETHPy150Open GoogleCloudPlatform/appengine-opencv-sudoku-python/main.py SolveStage.post/VarMisuse@144/390 `resp`->`filename`