M
M
Morrowind2021-04-08 21:50:08
Flask
Morrowind, 2021-04-08 21:50:08

How to properly connect js file to html in flask context?

Hey!
Here I have a gag in connecting the script1.js file.
I tried to connect using the following methods both in the header and at the bottom of the entire html code:

<link href="{{ url_for('static', filename='script1.js') }}" rel="stylesheet">
  <script src="script1.js"></script>
<script src="{{ url_for('static', filename='jquery.js') }}"></script>


But I get an error from the clicer() function that is activated when the button is clicked: The

606f4f0410dcc190746773.png

CSS method below connects with a bang. With js, they are in the same STATIC folder (as per the flask manual)


If js is entered into html itself, then everything works fine.

The very structure of folders and files:
606f50586bda1240873772.png

Why does html stubbornly refuse to see the local js file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Morrowind, 2021-05-17
@hekkaaa

Found the answer myself.
Should be used in html in header.
File path -> static\js\autchscript.js

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question