How to get absolute URL in Pylons?

How to get absolute URL in Pylons?

+4
source share
1 answer

To create a complete URL with routes, use the qualified=True keyword in the 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 runs behind a load balancer or reverse proxy server, you may run into problems when the generated URLs point to backend appservers and not to a third-party proxy server. You can use the host argument to fix this:

 print url("blog", id=123, qualified=True, host="example.com") # ==> "http://example.com/blog/123" 

For more information on settings and settings, see the Routing Guide .

+8
source

All Articles