Build URLs with url_for
Generate links from endpoint names, not hardcoded paths.
Hardcoded URLs Are Fragile
Typing "/user/alice" by hand breaks the day you rename a route. Flask offers url_for to build links from your view names instead.
Build by Endpoint Name
url_for takes the view function name and returns its path. Change the route string later and every generated link updates automatically. 🔗
from flask import url_for
url_for('home')