routes.py causing loss of css

42 views
Skip to first unread message

David Ripplinger

unread,
Aug 26, 2015, 11:33:53 AM8/26/15
to web2py-users
Hi everyone,

I know I'm doing something wrong here. I'm trying out app-specific routes.py files. I have an app that currently has the default/index page unmodified, that is, it's equivalent to the welcome app.

I have in the web2py base directory the following contents in my routes.py file:
routes_app = (
 
('/$anything', 'myapp'),
 
)

I have in the application directory myapp the following contents in my routes.py file:
routes_in = (
 
('/$anything', '/myapp/default/index'),
 
)

I just wanted to see if, with these initial rules, I could simply visit the url '/' and get to '/myapp/default/index'. More complex rules will be going in once I have this working. It loads the correct page, but it is entirely unformatted, making me think that somehow the css file didn't get through or something.

I don't know if it's significant, but I'm running web2py on localhost with ssl using:
web2py.exe -c ssl/server.crt -k ssl/server.key

I observed normal behavior with the ssl before introducing the routes.py files.

Is there something I'm doing wrong?

Anthony

unread,
Aug 26, 2015, 11:45:42 AM8/26/15
to web2py-users
Your routes.py maps literally any URL (including static URLs) to just the single /myapp/default/index URL. When using $anything in the first item of the tuple, you should also append it to the second so whatever arbitrary part of the original URL was matched gets retained. In any case, you probably don't want to match /$anything to a specific controller and function (at least not as the first rule, as that will match all incoming URLs).

If you just want to eliminate the application name for URLs and specify a default controller and function, the parameter-based rewrite system is a better option.

Anthony

David Ripplinger

unread,
Aug 26, 2015, 11:48:45 AM8/26/15
to web2py-users
Thank you, Anthony. That helps. In my app, things will soon get complex enough that the pattern-based system will suit me best. With your help, I think I understand it a bit better now. I got it to work for what I need in this first test by simply removing '$anything'.

Niphlod

unread,
Aug 26, 2015, 11:48:47 AM8/26/15
to web...@googlegroups.com

ahem..... you're rewriting ANYTHING to a single url. Can you see why there's something clearly wrong with your scheme ? :D

if you want MULTIPLE urls to work, you need to leave something on the left and the right side to be the "unique" parts of the urls.

if you want / to go to /app/default/index , the syntax is

'/', '/app/default/index'

while 

'/$anything', '/app/default/index'


is - correctly - collapsing all requests to that function

Reply all
Reply to author
Forward
0 new messages