GAE redirection with a delay

2019-02-20 16:33发布

Is that possible to redirect to another url with a delay in GAE? I know I can use JavaScript for this purpose, but may be there is a way to do delayed redirection without it? Now I use self.redirect("/") from GAE tutorial. Thanks.

2条回答
Bombasti
2楼-- · 2019-02-20 16:58

You can use the <meta http-equiv="refresh" content="x;url=http://yoururl/"> tag where x is the number of seconds to wait before redirect. This tag would go in <head> part of the generated page.

查看更多
一纸荒年 Trace。
3楼-- · 2019-02-20 17:23

import time at the top of your module and do a time.sleep(0.5) before you do a self.redirect call. The sleep argument can take a floating point value of number of seconds to delay. Just make sure that you don't exceed 30 seconds of delay as GAE expects that every request be handled within that otherwise it will be interrupted.

查看更多
登录 后发表回答