Dennis
Dennis

Reputation: 29

Server cannot locate javascript file

I am trying to run a function from my javascript code, I have called linked the js function in my file

This is my structure:

project
   static
      css
        /main.css
      js
        /script.js
   templates
        /layout.html

This is what I have tried, placing it in my head tags

<script type="text/javascript" src="{{ url_for('static', filename='script.js') }}" ></script>

If I try filename ='js/script.js' - and specific the folder, neither works

My error in the js console is:

Failed to load resource: the server responded with a status of 404 (NOT FOUND) http://127.0.0.1:5000/js/script.js

Thanks for any suggestions!

Upvotes: 0

Views: 90

Answers (1)

Soufiane Hassou
Soufiane Hassou

Reputation: 17750

{{ url_for('static', filename='js/script.js') }}

Upvotes: 2

Related Questions