, kanaacademy python:
def user_agent(self):
return str(self.request.headers['User-Agent'])
def is_mobile_capable(self):
user_agent_lower = self.user_agent().lower()
return user_agent_lower.find("ipod") > -1 or \
user_agent_lower.find("ipad") > -1 or \
user_agent_lower.find("iphone") > -1 or \
user_agent_lower.find("webos") > -1 or \
user_agent_lower.find("android") > -1
https://khanacademy.kilnhg.com/Repo/Website/Group/stable/File/request_handler.py#115
In principle, a browser is mobile if the User-Agent request header with a bottom window contains the string ipod, ipad, iphone, webos or android. Once you know that the requestor is mobile, you can redirect to the mobile URL or configure your output for mobile devices.
source
share