need same values on each request in views file. instead of getting them on every request, used before_request
function , added them global dict:
options = {} @app.before_request def before_request(): options['ip'] = request.remote_addr options['useragent'] = request.user_agent.string
is solution or not? can recommend?
the correct answer use flask's g
object. can read here: http://flask.pocoo.org/docs/0.10/api/#flask.g
Comments
Post a Comment