0

I am writing a Flask server and am having trouble understanding how to start the app without running __main__ twice.

In a terminal, if I type python example.py it prints Starting the app. twice.

The contents of example.py are:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return some_object.get_something()

if __name__ == "__main__":
    print("Starting the app.")
    some_object = object()
    app.run(host="0.0.0.0", debug=True)

What am I missing here? Thanks in advance.

EngineerCamp
  • 661
  • 1
  • 6
  • 16

0 Answers0