-1

I moved chart.js into a folder named "static", then I added it to my html file but now the chart won't show in the web UI

My code:

What I get in the terminal:

"GET /chart.js HTTP/1.1" 404 -

What I get in the JavaScript console:

Failed to load resource: the server responded with a status of 404 (NOT FOUND)

Whats going on here? I made sure and confirm that chart.js exists in the static folder.

Thanks for the help.

ksns
  • 1
  • 2

1 Answers1

0

It seems as if you're making a request to http://127.0.0.1:5000/chart.js as if you're trying to create an endpoint that ends in chart.js, I believe your goal here is probably to use a route to return a static html file in which you import and use chart.js.

return a template documentation: https://flask.palletsprojects.com/en/2.0.x/tutorial/templates/

chart.js usage documentation: https://www.chartjs.org/docs/latest/

You'll want to build the chart inside the template, by following the chart.js instructions inside of an html file known as a template that you will return from the route if rendering the chart is your expected behavior. If that is the case I would also recommend renaming your route form chart.js to something more fitting like index

Ozzie
  • 139
  • 1
  • 3
  • 11
  • Hi, Thanks for your answer I tried following the documentation specifically "url_for('static', filename='style.css')" and "@app.route('/hello/') @app.route('/hello/') def hello(name=None): return render_template('hello.html', name=name)" with no luck. Also, I don't know why but under "My Code" the following should have been visible- – ksns Jul 06 '21 at 18:46