I have a web application using Flask and Jinja2. I would like to inject different API-keys depending on if I'm serving the site in production or testing.
I could inject them using the Jinja templating engine and use inline <script>
-tags to then access them from my other JS. But preferably I would like to have some kind of really simple template-string in my .js-files, like this:
_ready: Keen.ready(function() {
var client = new Keen({
projectId: $KEEN_PROJECT_ID$,
writeKey: $KEEN_WRITE_KEY$
});
and then replace those keywords when Flask serve the file. Of course changing the value of the constant depending on which environment the server is running.
Are there any good ways of doing this?