Refactor web.py