from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/callback', methods=['POST'])
def webhook_callback():
data = request.json
job_id = data['job_id']
status = data['status']
if status == 'Completed':
# Process the completed job
process_completed_job(job_id)
elif status == 'Failed':
# Handle the failed job
handle_failed_job(job_id)
return jsonify({"status": "received"}), 200
def process_completed_job(job_id):
# Retrieve the job result and process it
# You may need to call the /job/{job_id} endpoint to get the full result
pass
def handle_failed_job(job_id):
# Handle the failed job, e.g., log the error, notify the user, etc.
pass
if __name__ == '__main__':
app.run(port=5000)