In a Flask-RESTful based web service I need to access few meta informations across each request.
These meta informations can be created out by processing few request params and supposed to be used later on.
which is the idle way to make it available across the Request/Response cycle flask g object OR adding an extra attribute to request object (it works)
ie -
from flask import request
def add_attributes():
meta_info = {'abcd':'efg'}
request.meta_info = meta_info #it works
Or add this to the g object
from flask import g
def add_attributes():
meta_info = {'abcd':'efg'}
g.meta_info = meta_info
which method could I follow..?
Aucun commentaire:
Enregistrer un commentaire