Debug mode is also watch mode, meaning that it keeps automatically reloading the site after every save. It also provides detailed outputs in case of an error pinpointing exactly where the error happened and possible reasons as to why it happened. Debug mode is highly recommended during active development. You can either pass it as an argument right after initializing the app:
1app = Flask(__name__)
2app.debug = True
or pass it as an argument when the app is run:
1if __name__ == '__main__':
2app.run(debug=True)
I like to call the folder that keeps my web assets ‘assets’ instead of static. For me static represents the build of the site. To set a custom folder (name), you can pass an argument when initializing the app, like:
1app = Flask(__name__,static_folder="assets")
and then in templates:
1<script src="{{ url_for('static', filename='js/file.js') }}"</script>
In the templates, you would use url_for() to get static files.
1{{ url_for('static', filename='css/main.css') }}
Note that by default the location of the static folder is ‘/static’. You can change it however by passing custom arguments when initializing the app. In any case, the url_for() will get the defined/default location of the static folder and look for the file in there.
Adam Greenhall - Flask Sass Coffee template Digital Ocean - How to structure large Flask applications