-
-
Save tazjel/997786 to your computer and use it in GitHub Desktop.
web2py mobile browser detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Detect mobile device. Set to mobile view if available | |
from mobile.sniffer.detect import detect_mobile_browser | |
if detect_mobile_browser(request.env.http_user_agent): | |
mobile_view = '%s.mobile.%s' % (request.function, request.extension) | |
if os.path.exists(os.path.join(request.folder, 'views',request.controller, mobile_view)): | |
response.view = '%s/%s' % (request.controller, mobile_view) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment