mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2025-04-03 10:32:39 +00:00
28 lines
708 B
Python
28 lines
708 B
Python
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()
|