I am having some trouble getting started with using javascript files on my website (A Flask application). I start the website by running run.py which looks like this:
#!flask/bin/python
from app import app
app.run(debug=True)
In my html page I have the following code which gives a 404 error:
Error message:
My file structure looks like this:
Any hints to where I'm going wrong?
So your
index.html
is atapp/templates/index.html
, and your jQuery is atapp/javascript/jQuery.js
right?I think your path is wrong. Try this:
Try using
src="app/javascript/jquery.js"
.Also, I noticed you include jquery.js twice - on line 7 and 28.
Ah yes, luckily I am currently developing a flask application at the moment.
You are currently missing the static folder which by default flask looks into, a folder structure something like this:
Two important default folders that Flask will look into templates and static. Once you got that sorted you use this to link up with your javascript files from your html page:
Hope that helps any questions just ask.
Plus - A good article to read but not super related but it talks about the folder structure of flask is this: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps
Here is what helped me eliminate the jquery part of my Flask project
This was taken straight from Basic Template found in http://getbootstrap.com/getting-started/