I have an application with many threads. One of them is a flask that is used to implement the (axillary) API. It is used with low load and is never exposed to the Internet, so the built-in flask web server is great.
My current code is as follows:
class API:
def run():
app = flask.Flask('API')
@app.route('/cmd1')
def cmd1():
self.cmd1()
@app.route('/cmd2')
def cmd2()
self.cmd2()
app.run()
I feel like I did it wrong, because all the documents say "create a flash application at the module level." But I don’t want to do this - it will ruin my tests, and the API is a small part of a larger application that has its own structure and conventions (each "application" is a separate class running in one or more threads).
How can I use Flask inside a class?