Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5060

Python flask getting information loaded at initialization time into a routes handler? [duplicate]

$
0
0

I am writing a small Flask app which acts as a shim between third party service and my own code.

I have some information that I know at the time that I create the app (specifically log in credentials), that I want get into route handlers. What is the correct / idiomatic way of doing this?

I tried attaching it to the app or putting in app.config but when I run with heroku (which I presume has multiple workers) I don't seem to have this information.

from flask import Flask, gapp = Flask()@app.route('/myroute')def myroute():   config = app.config['config'] # name error   config = a..config # name errorif __name__ == '__main__':   config = load_config()   app.config['config'] = config # not visi   # g.config = config # cannot write to g outside a request   app.config = config

Viewing all articles
Browse latest Browse all 5060


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>