Search code examples
pythoncherrypy

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!


Solution

  • It has been a while since I played with CherryPy, but I think the following should work:

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