def update(idx): if 'api_key' in request.args: api_key = request.args.get('api_key') token = Token.find_one(by={'api_key_hash': api_key}) if token is not None: job = Job.find_one(idx) if job is None: return jsonify(error='Not Found'), 404 data = request.get_json() if 'status' in data: job.set_status(data.get('status')) if 'result' in data: job.set_result(data.get('result')) return jsonify(job.to_dict()) else: return jsonify(error='Wrong API key'), 401 else: return jsonify(error='No API key'), 401
def read(idx): job = Job.find_one(by={'id': idx, 'user_id': current_user.id}) if job is None: return jsonify(error='Not Found'), 404 return jsonify(job=job.to_dict())