Easy Method to Handle Static JS Files During Flask Development

Shawn Hymers
Aug 6, 2020 · 4 min read

If your project has many JS files in the static directory, maintaining import links can be a pain.

This is a simple method to import all JS files from the static directory with three lines of code:

{% for file in js_files %}
<script type="text/javascript" src = {{file}}> </script>
{% endfor %}

Now I will explain how to generate and pass the js_files object to the front end.