You’re running Flask
in debug mode, which enables the reloader (reloads the Flask server when your code changes).
Flask can run just fine in a separate thread, but the reloader expects to run in the main thread.
To solve your issue, you should either disable debug (app.debug = False
), or disable the reloader (app.use_reloader=False
).
Those can also be passed as arguments to app.run
: app.run(debug=True, use_reloader=False)
.