How to get absolute url in Pylons ?
To generate a fully qualified URL with Routes, use qualified=True
keyword in url()
call.
Example:
print url("blog", id=123, qualified=True)
# depending on routing configuration,
# would print something like "http://somehost/blog/123"
If your web application is running behind load balancer or reverse proxy, you might get into issues where generated URLs point to backend appservers not the frontend proxy / load balancer. You can use host
argument to correct for that:
print url("blog", id=123, qualified=True, host="example.com")
# ==> "http://example.com/blog/123"
Refer to Routes manual for more options and tweaks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With