-1

Trying to create a simple website using HTML5 and have the following code...

<!DOCTYPE html>

<html lang="en">
    <head>
        <title>Generic Title</title>
    </head>
    <body>
        <audio controls>
            <source src="audio.mp3" type="audio/mp3">
        </audio>
    </body>
</html>

Then when I try to quickly host the server locally using Flask, I get a error that says...

"GET /audio.mp3 HHTTP/1.1" 404 -

The audio file is in the same directory as the .html file so I don't know why I get this error. Thank you for the help!

  • Actually, you can put the .mp3 on the ```static``` folder first. Read for static documentation [here](https://flask.palletsprojects.com/en/1.1.x/tutorial/static/). another [question](https://stackoverflow.com/questions/55933447/serving-static-files-from-static-folder-with-flask) seems similar. – apridos Nov 22 '20 at 04:09

1 Answers1

0

Add a ./ at the front of your src value, which will tell the browser to look for the file in the current directory, rather than at the site root, /:

<source src="./audio.mp3" type="audio/mp3">

selfagency
  • 1,481
  • 1
  • 9
  • 12
  • For some reason, even though I added a ./ to my filename, it still gives me a 404 error even though the file-path directly links to the mp3 file. Is there anything else that might be an issue? Thanks – KrimsonWolf Nov 22 '20 at 05:56
  • I missed that you had mentioned you were using Flask. You should refer to the two answers linked to above. – selfagency Nov 22 '20 at 16:46