0

I have a python program which is running Flask. I noticed a strange thing, it looks like the program is running twice, which I do not want.

Here is the file for starting the program(runserver.py, in the root folder /):

from myapp import app

if __name__ == "__main__":
    print "woho"
    app.run(host='0.0.0.0',debug=True)

When running this, I can see two "woho" in the terminal, indicating that something is strange.

in the folder /myapp I have __init__.py:

from flask import Flask

app = Flask(__name__) 

import myapp.views

and then in my views.py (also in /myapp) I have all the views like:

from myapp import app
from flask import render_template

@app.route('/')
def index():
    return render_template('index.html')
rablentain
  • 6,641
  • 13
  • 50
  • 91

1 Answers1

6

it's due to the reloader of flask/werkzeug, which reloads automatically when you change the code.

so give debug=False if you don't want/need that, e.g. for "production".

How to stop Flask from initialising twice in Debug Mode?

Community
  • 1
  • 1
Thomas Waldmann
  • 501
  • 2
  • 7