Separating html and JavaScript in Flask [duplicate]

You need to invoke the url_for function within a markup so that the correct url be resolved, i.e.

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

Please consider following the Quick Start guide fully as it will help with other issues you might have.