def test(): response = flask.make_response(flask.render_template( 'aws/debug.html', title='Test', agent=util.user_agent(), timestamp=datetime.utcnow(), get_url=util.get_url(), host=flask.request.host, country=util.geoip_country(), ip=flask.request.headers.get('X-Forwarded-For') or flask.request.remote_addr, )) return response
def decorated_function(*args, **kwargs): p = flask.request.path browser_check = p.endswith('/') or p.endswith('.html') browser_check = browser_check and not p.startswith('/test/') if browser_check: try: agent = util.user_agent() if agent['is']['mobile']: return flask.abort(406) if not util.check_browser(agent): return flask.abort(406) except KeyError: return flask.abort(406) return f(*args, **kwargs)
def browser_test(): return flask.jsonify(util.user_agent())
def test_agent(): return flask.jsonify(util.user_agent())