3

I'm new with python and I want to make a browser controlled piece of software to run on my raspberry pi.

This is my Main() function, stripped from most of the code to focus on the problem:

def Main():

    print "Starting Flaskserver"
    app = Flask(__name__)

    @app.route('/')
    def root():
        return render_template("test.html")

    if __name__ == '__main__':
        app.run(host='0.0.0.0', port=80, debug=True)    

if __name__ == '__main__':
Main()

If I run this script, I notice in the console the script runs twice (print "Starting flaskserver"):

Starting Flaskserver
* Running on http://0.0.0.0:80/
* Restarting with reloader
Starting Flaskserver

test.html contains just a title...

What am I doing wrong?

Greetings

Parrot
  • 31
  • 1
  • 3

1 Answers1

4

You're running the development server, with debug=True - this causes the server to run with the reloader which looks for changes in your file system to reload your app. Because of this, your app is restarted in a new process by the reloader process.

That's what is meant by the message Restarting with reloader

Matt Healy
  • 18,033
  • 4
  • 56
  • 56