routes.py question

18 views
Skip to first unread message

mr.freeze

unread,
Jul 1, 2009, 10:51:00 PM7/1/09
to web2py Web Framework
Can I use routes.py to make my application run from:
http://myserver
instead of:
http://myserver/myapp

If not, can it be done another way? My domain name and app are the
same name so it ends up looking weird:
http://myweb2pyapp.com/myweb2pyapp (fake names but hopefully you get
the idea)

Thanks

ceej

unread,
Jul 1, 2009, 10:55:50 PM7/1/09
to web2py Web Framework
yes you can do:

routes_in=(
('/admin(?P<stuff>.*)', '/admin\g<stuff>'),
('/login(?P<stuff>.*)', '/myapp/auth/login\g<stuff>'),
('/logout(?P<stuff>.*)', '/myapp/auth/logout\g<stuff>'),
('/register(?P<stuff>.*)', '/myapp/auth/register\g<stuff>'),
('/verify_email(?P<stuff>.*)', '/myapp/auth/verify_email\g<stuff>'),
('/change_password(?P<stuff>.*)', '/myapp/auth/change_password
\g<stuff>'),
('/retrieve_password(?P<stuff>.*)', '/myapp/auth/retrieve_password
\g<stuff>'),
('/myapp/(?P<stuff>.+)', '/myapp/\g<stuff>'),
('/$controller', '/myapp/$controller/index'),
('^.*:/$', '/myapp/main/index'),
('/(?P<stuff>.+)', '/myapp/\g<stuff>'),
)
routes_out=(
('/admin(?P<stuff>.*)', '/admin\g<stuff>'),
('/myapp/auth/login/(?P<stuff>.*)', '/login/\g<stuff>'),
('/myapp/auth/logout/(?P<stuff>.*)', '/logout/\g<stuff>'),
('/myapp/auth/register/(?P<stuff>.*)', '/register/\g<stuff>'),
('/myapp/auth/verify_email/(?P<stuff>.*)', '/verify_email/
\g<stuff>'),
('/myapp/auth/change_password/(?P<stuff>.*)', '/change_password/
\g<stuff>'),
('/myapp/auth/retrieve_password/(?P<stuff>.*)', '/retrieve_password/
\g<stuff>'),
('^/myapp/main/index$','/'),
('/myapp/(?P<stuff>.+)', '/\g<stuff>'),
)
routes_onerror = [
('init/400', '/myapp/error/not_found')
,('init/*', '/myapp/error/fail')
,('*/404', '/myapp/error/not_found')
,('*/*', '/myapp/error/index')
]

error_message = '<html><body><h1>Invalid request</h1></body></html>'
error_message_ticket = '<html><body><h1>Internal error</h1>Ticket
issued: <a href="/admin/default/ticket/%(ticket)s" target="_blank">%
(ticket)s</a></body></html>'

On Jul 1, 9:51 pm, "mr.freeze" <nat...@freezable.com> wrote:
> Can I use routes.py to make my application run from:http://myserver
> instead of:http://myserver/myapp
>
> If not, can it be done another way?  My domain name and app are the
> same name so it ends up looking weird:http://myweb2pyapp.com/myweb2pyapp(fake names but hopefully you get
> the idea)
>
> Thanks

ceej

unread,
Jul 1, 2009, 10:56:55 PM7/1/09
to web2py Web Framework
in your routes.py file, just add to routes.example.py and rename to
routes.py.

On Jul 1, 9:51 pm, "mr.freeze" <nat...@freezable.com> wrote:
> Can I use routes.py to make my application run from:http://myserver
> instead of:http://myserver/myapp
>
> If not, can it be done another way?  My domain name and app are the
> same name so it ends up looking weird:http://myweb2pyapp.com/myweb2pyapp(fake names but hopefully you get
> the idea)
>
> Thanks

mr.freeze

unread,
Jul 1, 2009, 11:16:52 PM7/1/09
to web2py Web Framework
Thank you ceej. This will be for a single app install. I found this
in the manual just now (I swear I looked before posting!):
routes_in=(
('/(?P<any>.*)','/init/\g<any>'),
)
routes_out=(
('/init/(?P<any>.*)','/\g<any>'),
)

It seems to be working as advertised.
Any drawbacks compared to your method?

On Jul 1, 9:56 pm, ceej <cjlaz...@googlemail.com> wrote:
> in your routes.py file, just add to routes.example.py and rename to
> routes.py.
>
> On Jul 1, 9:51 pm, "mr.freeze" <nat...@freezable.com> wrote:
>
> > Can I use routes.py to make my application run from:http://myserver
> > instead of:http://myserver/myapp
>
> > If not, can it be done another way?  My domain name and app are the
> > same name so it ends up looking weird:http://myweb2pyapp.com/myweb2pyapp(fakenames but hopefully you get
> > the idea)
>
> > Thanks

Yarko Tymciurak

unread,
Jul 2, 2009, 4:49:57 AM7/2/09
to web...@googlegroups.com
well, there is a simpler thing:

if you go to http://myserver/

web2py tries - in order - to start an app called "init";  if it doesn't exist, it looks for an app called "welcome".

The first level, most simple solution is to just call your app "init".

You can use routes, then, for less trivial things.

Hope that helps.

- Yarko
Reply all
Reply to author
Forward
0 new messages