Massimo, Can you please show us more specifically how to do this? (I think someone also asked the same question in a previous topic).
Thanks. On Oct 24, 1:25 pm, mdipierro <[email protected]> wrote: > This assumes web2py is serving static files. But it does not prevent > you to use a apache for it. > In this case you would need the virtual hosts for the different apps. > > On Oct 24, 1:18 pm, VP <[email protected]> wrote: > > > Can Massimo or someone clarify if this tip will result in web2py > > serving static files or Apache serving static files? > > > Is this a "production" (high-performance) set up? The assumption "one > > domain per app" appears to suggest that this is a production set up. > > Yet, Massimo mentioned in an early tip similar to this that web2py > > would be serving static files, and is thus not meant for production. > > > Can someone clarify please? > > > Thank you. > > > On Oct 17, 9:03 pm, mdipierro <[email protected]> wrote: > > > > Replace your web2py/routes.py with this: > > > > ------------- begin routes.py----------- > > > try: config=open('routes.conf','r').read() > > > except: config='' > > > def auto_in(apps): > > > routes=[ > > > ('/robots.txt','/welcome/static/robots.txt'), > > > ('/favicon.ico','/welcome/static/favicon.ico'), > > > ('/admin$a','/admin$a'), > > > ] > > > for a,b in [x.strip().split() for x in apps.split('\n') \ > > > if x.strip() and not x.strip().startswith('#')]: > > > if not b.startswith('/'): b='/'+b > > > if b.endswith('/'): b=b[:-1] > > > app = b.split('/')[1] > > > routes+=[ > > > ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b), > > > ('.*:https?://(.*\.)?%s:$method /static/$a' % a,'%s/static/ > > > $a' % app), > > > ('.*:https?://(.*\.)?%s:$method /appadmin/$a' % a,'%s/ > > > appadmin/$a' % app), > > > ('.*:https?://(.*\.)?%s:$method /$a' % a,'%s/$a' % b), > > > ] > > > return routes > > > > def auto_out(apps): > > > routes=[] > > > for a,b in [x.strip().split() for x in apps.split('\n') \ > > > if x.strip() and not x.strip().startswith('#')]: > > > if not b.startswith('/'): b='/'+b > > > if b.endswith('/'): b=b[:-1] > > > app = b.split('/')[1] > > > routes+=[ > > > ('%s/static/$a' % app,'static/$a'), > > > ('%s/appadmin/$a' % app, '/appadmin/$a'), > > > ('%s/$a' % b, '/$a'), > > > ] > > > return routes > > > > routes_in=auto_in(config) > > > routes_out=auto_out(config) > > > ------------------- END --------------- > > > > what does it do? It writes routes for you based on a simpler routing > > > configuration file called routes.conf. here is an example: > > > > ----- BEGIN routes.conf------- > > > 127.0.0.1 /examples/default > > > domain1.com /app1/default > > > domain2.com /app2/default > > > domain3.com /app3/default > > > ----- END ---------- > > > > It maps a domain (the left had side) into an app and it shortens the > > > URLs for the app, by removing the listed path prefix. That means > > > >http://domain1.com/indexwillbemapped into > > >/app1/default/indexhttp://domain2.com/indexwillbemapped into > > >/app2/default/index > > > > It is safe in that it preserves admin, appadmin, static files, > > > favicon.ico and robots.txt. > > > >http://domain1.com/favicon.icohttp://domain1.com/robots.txthttp://dom...... > > > /admin/...http://domain1.com/appadmin/... > > >/app1/appadmin/...http://domain1.com/static/... /app1/static/... > > > > and vice-versa. > > > > It does assume one app per domain. > > > > I think something like this should be default since lots of people > > > find routes.py hard to work with. > > > Comments? Suggestions? > > > > Massimo > >

