In these situations, most people would want to create a custom CLI command that callsapp.run()to start the application after applying any necessary changes, such as enabling profiling, etc. Examplebug.py: fromflaskimportFlaskapp=Flask(__name__)@app.cli.command()defcustom_run():app.run() ...