Running a site and its corresponding url shortener on the same web2py instance

25 views
Skip to first unread message

Spokes

unread,
Dec 28, 2014, 8:40:10 AM12/28/14
to
I'd like to run a site and a dedicated url shortener on the same instance of web2py. These are two different apps (let's call them MainApp and Short) corresponding to two different domains (let's say, mainapp.com and short.me). I've managed to set up my routes.conf and routes.py file such that things seem to be routing properly. However, I'd like to be able to pass strings of numbers as arguments to the Short app's default/index function in this way: "short.me/[some number]"; I'm not quite sure how to set up the routes file to accomplish this. Can somebody suggest modifications to the routes files that would permit passing numerical arguments? Thanks.

routes.conf:

http
://mainapp.com/ /MainApp/default
http
://short.me/ /Short/default

routes
.py:

routers
= dict(
  BASE  
= dict(
      domains
= {
         
'mainapp.com': 'MainApp',
         
'short.me:':'Short',
     
}
 
),
)

The Short app's default function looks like this:

def index():
    redirect
(URL('default', 'redirect', scheme='http', host='mainapp.com',
        vars
= dict(id = request.args(0))))






Spokes

unread,
Dec 28, 2014, 1:59:31 PM12/28/14
to web...@googlegroups.com
Nevermind. This solution seems to have worked: https://groups.google.com/d/msg/web2py/yi5rPK4APKs/rVBg9AiShPUJ
Reply all
Reply to author
Forward
0 new messages