import json, sys from tornado.ioloop import IOLoop from tornado.web import RequestHandler, Application from tfw.config import tfwenv sys.path.append(tfwenv.WEBIDE_WD) from login_component import authorize_login class LoginHandler(RequestHandler): def post(self, *args, **kwargs): request = json.loads(self.request.body) email, is_admin = authorize_login( request['email'], request['password'] ) self.write({ 'email': email, 'is_admin': is_admin }) if __name__ == '__main__': application = Application([(r'/login', LoginHandler)]) application.listen(tfwenv.LOGIN_APP_PORT) IOLoop.instance().start()