Have fun. And as always, let
me know if you have problems or suggestions.
""".format(appName=appName, params=params)
def printNonAndroid(agent):
subject = 'Android device not identified'
body = 'My browser is running on an android device but says its' \
+ ' user agent is: \"{agent}\". Please fix your website' \
+ ' to recognize this as an Android browser'.format(agent=agent)
fmt = """
This page is meant to be viewed on an Android device.
(If you are viewing this on an Android device,
you've found a bug! Please email me.
"""
return fmt.format(subject=subject, body=body)
def index(req):
str = printHead()
typ = os.path.basename(os.path.dirname(req.filename))
if 'andd' == typ: appName = 'CrossDbg'
else: appName = 'CrossWords'
agent = req.headers_in.get('User-Agent', None)
if agent and 'Android' in agent:
str += printAndroid(appName, req.args)
else:
str += printNonAndroid(agent)
str += printTail()
return str