I’m trying to play an mp3 file from JavaScript in a Flask framework.
Inside of the js file, I have:
let audio = new Audio('bell.mp3');
audio.play();
I’m getting a 404 error so it can’t find the mp3 file.
My project folders look like this:
main.py
templates
home.html
Static
Scripts
script.js
bell.mp3
I also tried to put the bell.mp3 file in templates and in the root folder, but it still can’t find it. How do I access it through javascript with the flask framework? I just found out I have to put js and css into a Static folder for flask and I still don’t really know why so I’m wondering if I have to do something else weird like that.