I'm new to web.py. Trying to setup redirection as explained in the documentation. However, when I send a curl request for localhost:8080/health/
the application returns None
instead of the HAPPY
import web
urls = (
#url, #class_name
'/', 'index',
'/(.*)/', 'redirect', # match localhost:port/somepath/
'/health', 'health'
)
class index:
def GET(self):
return 'Hello World!'
# this is faulty and not redirecting as expected
class redirect:
def GET(self, path):
web.seeother('/' + path)
class health:
def GET(self):
return "HAPPY"
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
Your python code is fine. The problem is your use of curl.
By default, curl won't follow redirects unless instructed. Add the -L option and you're good to go.
$ curl -L http://localhost:8080/health
HAPPY