librelist archives

« back to archive

Communicating between tornado and flask

Communicating between tornado and flask

From:
Hegemone Sosapi
Date:
2014-02-19 @ 19:14
Hi,

I have a, possibly stupid, question about tornado and flask that may
actually be more of a general python issue. I'm trying to wrap a flask app
I wrote before I knew how I was going to productionize it. I later decided
on Tornado, but I'm having trouble determining how I should passthrough the
cli args I supply to the tornado script to the flask app it wraps
(originally I was passing these args directly on cli to the flask script).

It seems like one option is to set globals and access them from the flask
app, but that doesn't feel like the right thing to do. Another option that
crossed my mind was wrapping the flask app in a class, so that I could
create an instance of that class, set its attributes based on cli args and
call a method on the class that returns a flask app instance I could pass
to the tornado wsgi wrapper.

I'm not only looking for any possible solution, but obviously recommended
solutions (or recommended alternatives).