routes_app in the base routes.py to determine from an incoming URL the name of the application to be selected ". Does imply a bit more than this. Pattern based routing is confusing enough already.Okay, I get it now, routes_app does not select the application, only where to get the substitute routes.py. The book is right with hindsight, but did not lead me to the right understanding. Maybe it should be clearer that it only controls which routes.py is used.The phrase " This is enabled by configuringroutes_appin the base routes.py to determine from an incoming URL the name of the application to be selected ". Does imply a bit more than this. Pattern based routing is confusing enough already.Could you now explain the following.If I have a URLThis selects my gallery app.If in routes.py I putroutes_in = (('/gallery','/welcome'),)It does now route127.0.0.1:8002/gallery to the welcome app.However if I change the routes_in toroutes_in = (('2/gallery','2/welcome'),)it no longer routes127.0.0.1:8002/gallery to the welcome app, but leaves it as the gallery app, so routes_in is no longer working.Why is this?
"The general syntax for routes is more complex than the simple examples we have seen so far. Here is a more general and representative example:
1. | routes_in = ( |
I would like, within routes_In to be able to route according to domain name.
So what would routes_in look like to route
127.0.0.1:8002 to welcome, and
localhost:8002 to admin
I am not sure what docs you are referring to Jonathan. The book gives an example:"The general syntax for routes is more complex than the simple examples we have seen so far. Here is a more general and representative example:
"
1.
2.
3.
4. routes_in = (
('140\.191\.\d+\.\d+:https://www.web2py.com:POST /(?P<any>.*)\.php',
'/test/default/index?vars=\g<any>'),
)that seems to imply the URL is a string. It would be useful if one could see the URL presented to routes_in.
'[remote address]:[protocol]://[host]:[method] [path]'Let me ask the second part of my initial post slightly revised.I would like, within routes_In to be able to route according to domain name.
So what would routes_in look like to route
127.0.0.1:8002 to welcome, and
localhost:8002 to admin
A little below that is the general structure of the incoming pattern.
'[remote address]:[protocol]://[host]:[method] [path]'
Are you trying to match the remote address as localhost? The problem is that it depends on what you browser puts in there. You can try:
routes_in = [('127\.0\.0\.1:http://.*?:(GET|POST) /$anything','/welcome')]
routes_in = [('127\.0\.0\.1:http://.*?:(get|post) /$anything','/welcome')]
works