I am attempting to serve static mp3 files with Flask so I can embed these mp3 files in an HTML audio block. I seem to be having an issue setting up the path correctly but I am not entirely sure if my problem is in my python or html.
An outline of my project:
music
app.py
static
button.js
MDF.mp3
templates
button.html
My app initialization in app.py looks like
app = Flask(__name__, static_url_path="", static_folder="static")
The route in app.py looks like
@app.route("/<path:filename>")
def upload1():
return send_static_file("MDF.mp3")
My default route:
@app.route("/", methods=["GET"])
def home():
return render_template("button.html", title="Music Box", name="MyName", song1=songList[0], song2=songList[1], song3=songList[2])
And my button.html looks like
<!DOCTYPE html>
<html lang=en-US xml: lang"en-US">
<body>
<o1>
<li> {{song1}}</li>
<audio controls>
src=upload1():
Your browser does not support the <code>audio</code> element.
</audio>
<li> {{song2}}</li>
<audio controls>
src=upload2():
Your browser does not support the <code>audio</code> element.
<li> {{song3}}</li>
<audio controls>
src=upload3():
Your browser does not support the <code>audio</code> element.
</ol>
<script src="/static/button.js"></script>
</body>
</html>
The error code I get is
10.245.81.226 - - [01/May/2019 04:25:08] "GET / HTTP/1.1" 404 -
10.245.81.226 - - [01/May/2019 04:25:08] "GET /static/button.js HTTP/1.1" 404 -
10.245.81.226 - - [01/May/2019 04:25:08] "GET /favicon.ico HTTP/1.1" 404 -