I'm trying to develop a small music app using Flask and Docker. I have two docker services in my compose, both running Flask.
The first one is called uploader:
@app.route("/get_song/<string:filename>/", methods=["GET"])
def get_song(filename):
path = os.path.join(flask.current_app.instance_path, flask.current_app.config["UPLOAD_FOLDER"])
return flask.send_from_directory(path, filename, as_attachment=True)
The second one renders a Jinja template which attempts to play the file returned by this API:
<audio controls="controls" autoplay="autoplay"></audio>
<a href="javascript:void(0);" onclick="playSong('{{song}}')">{{song}}</a>`
<script type="text/javascript">
function playSong(song){
$('audio').attr('src', 'http://uploader:5000/get_song/'+song);
}
</script>
Separately, these components work just fine. But when used together, the file doesn't play. I've tried pretty much everything I found online and nothing seems to work. Any help would be extremely appreciated. Thanks!
Edit: Added docker-compose file. Both docker images are built locally.
version: "3"
services:
uploader:
image: project_uploader:latest
ports:
- "4000:5000"
networks:
- upload
frontend_server:
image: project_frontend_server:latest
ports:
- "5000:5000"
networks:
- upload
networks:
upload: