How can I specify the port used for the Flask url_for method? Or, can I configure Flask to use whatever port it is running on for url_for? My issue is that I’m running a server on port 8080 but url_for does not add this port to any URLs generated, so any generated URLs use port 80 and do not resolve.
How can I specify the port used for the Flask url_for method? Or, can
Share
It seems the only way to specify a port in
url_foris to use the_external=Trueargument like so:This generates a URL like
http://localhost:5000/contact-us. Unfortunately a:5000/contact-usisn’t a valid relative URL. So without using a full, external URL, the port cannot be specified.