crafty-4/app/classes/web/base_handler.py

17 lines
446 B
Python
Raw Normal View History

2020-08-12 00:36:09 +00:00
import logging
import tornado.web
logger = logging.getLogger(__name__)
class BaseHandler(tornado.web.RequestHandler):
def get_remote_ip(self):
remote_ip = self.request.headers.get("X-Real-IP") or \
self.request.headers.get("X-Forwarded-For") or \
self.request.remote_ip
return remote_ip
def get_current_user(self):
return self.get_secure_cookie("user", max_age_days=1)