-1

I'm trying to implement a flask website where there will be music playing. The audio folder doesn't "upload" (I'm not sure if it's the correct term, that's also part of my problem) to the browser. It doesn't seem like the html pages have access to those files. Those are my project folders in Visual Studio Code. Notice the audio folder (it contains mp3 files) Those are my project folders in Visual Studio Code. Notice the audio folder (it contains mp3 files)

And this is the "sources" tab in chrome (It does the same with microsoft edge) inspect menu when I "flask run" or "python app.py" files the website has access to

The Audio file is gone, and I don't know why.

I've researched how to serve static files with Flask, but I don't understand how it can help me. I've experimented with send_static_file, but I don't think that's what I need at all.

I've completely ran out of ideas on why this could be, and any help or tip will be very appreciated.

1 Answers1

0

You need to incorporate the audio you want to play in the template:

<audio controls>
   <source src="{{ url_for('.static', filename='audio/your song.mp3') }}" type="audio/mpeg">
   Your browser does not support the audio element.
</audio>
Dionys
  • 3,083
  • 1
  • 19
  • 28
  • It already is, but the audio tag (whatever the right name is) doesn't have any songs on it... the time says 0:00 of 0:00 and nothing plays. I included the audio tag in the template, It works on its own with the local website (without flask), and the error is not from the url_for() (it displays the correct one in source)... The problem really comes from the file not uploading (or whatever the correct word is) – Julien Audet Apr 14 '20 at 02:26