How can I Have Cherry Py redirect a browser to a website?

I was trying to make a Cherry Py page that would redirect the client to a certain site on a certain day of the week. I tried doing webbrowser.open('sitename.com') but that simply opened the website in the console. Is there a way you can have it redirect? Note:This is hosted on a Linux box I have offsite and not client side. All help is appreciated!


自从我和CherryPy一起玩了一段时间,但我认为以下几点应该可以发挥作用:

raise cherrypy.HTTPRedirect("www.newsite.com")

@EricS answer is totally right and works, but you need to pay attention that it will default to a 303 http error code. If you need a 301 or 302 you need to do the following:

raise cherrypy.HTTPRedirect("www.newsite.com", status=301)
链接地址: http://www.djcxy.com/p/15736.html

上一篇: CSS更改hr标签的颜色

下一篇: 我如何让Cherry Py将浏览器重定向到网站?