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!
Asked
Active
Viewed 2,488 times
2

ollien
- 4,418
- 9
- 35
- 58
2 Answers
3
It has been a while since I played with CherryPy, but I think the following should work:
raise cherrypy.HTTPRedirect("www.newsite.com")

EricS
- 9,650
- 2
- 38
- 34
1
@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)

Javier
- 1,027
- 14
- 23