I tried fetching an audio file from the API using the composer's name and the name of the audio, but it returned an error. Does the API's database have the composer's work in an audio format, if it does, how can I fetch it?
This was the function I ran;
@app.route('/audio//')
def get_audio(composer, work):
url = f"https://openopus.org/{composer}/{work}.mp3"
response = requests.get(url)
if response.status_code == 200:
return response.content, 200, {'Content-Type': 'audio/mpeg'}
else:
return jsonify({'error': 'Unable to fetch audio file.'}), 500
I tried fetching an audio file from the API using the composer's name and the name of the audio, but it returned an error. Does the API's database have the composer's work in an audio format, if it does, how can I fetch it?
This was the function I ran;
@app.route('/audio//')
def get_audio(composer, work):
url = f"https://openopus.org/{composer}/{work}.mp3"
response = requests.get(url)
if response.status_code == 200:
return response.content, 200, {'Content-Type': 'audio/mpeg'}
else:
return jsonify({'error': 'Unable to fetch audio file.'}), 500