Convert from flask to Tornado