Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get absolute url in Pylons?

How to get absolute url in Pylons ?

like image 744
uhbif19 Avatar asked Feb 25 '23 22:02

uhbif19


1 Answers

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.

like image 142
Pēteris Caune Avatar answered Mar 05 '23 14:03

Pēteris Caune