Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
web2py mobile browser detection
# 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 = '' % (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)
Copy link

mattgorecki commented Jul 21, 2011

This is for changing the view in web2py based on the browser agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment