I have an application with many threads. One of them is flask, which is used to implement (auxiliary) API. It's used with low load and never exposed to the Internet, so build-in flask web server is perfectly fine.
My current code looks like this:
class API: # ... all other stuff here, skipped def run(): app = flask.Flask('API') @app.route('/cmd1') def cmd1(): self.cmd1() @app.route('/cmd2') def cmd2() self.cmd2() app.run()I feel I done it wrong, because all docs says 'create flask app at module level'. But I don't want to do this - it messes up with my tests, and API is a small part of the larger application, which has own structure and conventions (each 'application' is a separate class running in one or more threads).
How can I use Flask inside class?