External JavaScript file is not getting added when running on Flask
Step 1: Create folder with name static on project root
Step 2: Add static files in static folder
Step 3 Add in template
<script type="text/javascript" src="{{ url_for('static', filename = 'hello.js') }}"></script>
Serve the map.js
file as a static resource:
move the file to a
static/
subdirectory of your packagegenerate a static URL for it in a Jinja2 template like so:
<script type="text/javascript" src="{{ url_for('static', filename='map.js') }}"></script>
The filename
parameter takes a relative path; you can use subdirectories was needed.