What is the search rule for static content when you link it within a heist template?
I get a few problems related to javascript files not being found.
So sticking my “myjavascript.js” and “jquery.js” into the root of “static” directory seems to be working when the URL supplied is, for instance, /index. If the URL is /something/index then it fails to locate my javascript files in the root of “static” directory. So putting them in “static/something” fixes it. Anyway, I ended up sprinkling copies of my javascript files all over the place so they can be found under different URL strings.
So, it is either I am using the wrong location or my links are incorrect within the template.
Given the link <script type="text/javascript" src="/js/jquery.js"> </script> where would it look for the file? What about src="jquery.js"?
I also get these type of errors from javascript console if I put the files under “static/js”:
Resource interpreted as Script but transferred with MIME type text/html: "http://0.0.0.0:8000/js/jquery.js". new:6
Uncaught SyntaxError: Unexpected token < :8000/js/jquery.js:1
Resource interpreted as Script but transferred with MIME type text/html: "http://0.0.0.0:8000/js/base.js". new:6
Uncaught SyntaxError: Unexpected token <
Thanks.
This totally depends on how you define your routes. I usually put my javascript in static/js, resources/js, or resources/static/js, but any location is fine. The key is how you route that directory. You probably have a route something like this:
(“static”, serveDirectory “resources/static”)
This means that if you have jquery.js in the resources/static directory, then it will be available at the url
http://localhost:8000/static/jquery.js. This would mean that you would putsrc="/static/jquery.js"in your script tag. The first part of the routing tuple determines the URL path and the second part of the tuple determines the directory on the local filesystem.