1

Every single time I run my python script, it reloads and thus runs the contents of the script twice.

This is a Flask application, and I have Debug=True, but I was under the impression it would only restart the server if I re-saved a file (which I'm not doing). Is it possible to change this behavior? As soon as I remove the Debug=True setting, it stops, but ideally I'd like to be able to have it on for the time being.

My basic run.py file:

from flask import Flask

app = Flask(__name__)
app.config.update(
  # DEBUG = True
)

if (__name__):
  app.run()
Jimmy Gong
  • 1,825
  • 5
  • 20
  • 35

1 Answers1

6

Yes, you can. Where you declare debug=True, add the argument use_reloader=False.

See the Flask API documentation on run for more details.

Tux
  • 1,896
  • 3
  • 19
  • 27