Redirect from / (root) to /index URL

71 views
Skip to first unread message

Kevin Keller

unread,
Feb 19, 2021, 8:27:58 AM2/19/21
to py4web
@action("/", method=['GET'])
def root:
    redirect(URL('index'))


This does not seem to work, how would you do it? 

Thanks!

Jim Steil

unread,
Feb 19, 2021, 9:27:51 AM2/19/21
to py4web
Can you try 

redirect(URL('/index')

-Jim

Kevin Keller

unread,
Feb 19, 2021, 10:23:52 AM2/19/21
to Jim Steil, py4web
Didnt work :(
cloudHQPowered by
cloudHQ

--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/618d1762-addf-4aa9-823b-20e6337c1297n%40googlegroups.com.

Kevin Keller

unread,
Feb 19, 2021, 10:26:21 AM2/19/21
to Jim Steil, py4web
Even if I point to random non existing page it does not work, so the function does not get called when using / for the root element. 

So I just need to know what the root url is in py4web?


cloudHQPowered by
cloudHQ

Jim Steil

unread,
Feb 19, 2021, 10:50:19 AM2/19/21
to py4web
How about the other way around

@action("index", method=['GET'])

def root:
    redirect(URL('index'))

or 

@action("index", method=['GET'])
def root:
    redirect(URL('/'))


index is then optional.

-Jim

Massimo DiPierro

unread,
Feb 19, 2021, 11:05:49 AM2/19/21
to Kevin Keller, py4web
Py4web threats .../index as an alias for ... Always

--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.

Kevin Keller

unread,
Feb 19, 2021, 2:31:32 PM2/19/21
to Massimo DiPierro, py4web
Cool, its just I have a custom form on this url:

AIC_Demo_Page/create_oidc_client

and it exponents to post information to :

AIC_Demo_Page/index

when I render the index page by going to : 

AIC_Demo_Page/

and then go to my form I will end up at : AIC_Demo_Page/create_oidc_client

But I should be at :

AIC_Demo_Page/index/create_oidc_client

Otherwise I will run into an error. 












cloudHQPowered by
cloudHQ

Massimo

unread,
Feb 20, 2021, 1:00:45 PM2/20/21
to py4web
It only truncates the /index at the end. If you specify the full path to
AIC_Demo_Page/index/create_oidc_client
it should wo what you want.

Reply all
Reply to author
Forward
0 new messages