How to make test web server serve my app at a special URL, rather than root?

11 views
Skip to first unread message

michael kapelko

unread,
Sep 28, 2011, 11:44:36 PM9/28/11
to web.py
Hi.
My app is served at http://IP/wsm/ for production, for testing I use
test web server and thus my app is served at http://IP:8080/
I'm forced to employ global "urlPrefix" variable and construct all
links with that variable.

I want the test server to serve my app at http://IP:8080/wsm/ so that
I don't need to change urlPrefix when either deploying, or testing. Is
there a way to do it?
Thanks.

Branko Vukelić

unread,
Sep 29, 2011, 3:16:36 AM9/29/11
to we...@googlegroups.com

Here's one way you could do it:

>>> import os
>>> urlPrefix = os.environ['APP_PREFIX'] or '/prefix'
>>> urls = ('/foo', 'foo', '/bar', 'bar')
>>> urls = map(lambda x: x[0] == '/' and urlPrefix + x or x, urls)
>>> urls
['/prefix/foo', 'foo', '/prefix/bar', 'bar']
>>>

--
Branko Vukelic
bra...@brankovukelic.com
bra...@herdhound.com

IDEA MACHINE
www.brankovukelic.com

Lead Developer
Herd Hound (tm) - Travel that doesn't bite
www.herdhound.com

Love coffee? You might love Loveffee, too.
loveffee.appspot.com

Zhang Huangbin

unread,
Oct 4, 2011, 4:33:53 AM10/4/11
to we...@googlegroups.com
How about pass web.ctx.homepath to template as a global variable, then use $ctx.homepath as URL prefix?
Reply all
Reply to author
Forward
0 new messages