title: API calls running twice using Waitress and Flask
body: <p>I've created an API using Flask. I followed the factory pattern of Flask documentation - the rules and names will be abstracted. (__init__.py of my_package)</p>
  
  <p>With the package and factory method done, I imported it into another file outside the package and created a small script to get the waitress server started (server.py file)</p>
  
  <p>Everything works as expected, but I detected that every time I make a request to the API, it runs twice. This can't happen, as some routes insert data into my database and this behaviour will keep inputting duplicates.</p>
  
  <p>How to properly solve this issue? Can I disable this double response?</p>
  
  <p>I've already tried setting <em>app.debug</em> and <em>app.use_reloader</em> to False, without any noticeable difference.</p>
  
  <p>I also tried to find some information in Waitress and Flask documentation but I could find anything that helped me.</p>
  
  <h1>Factory method of __init__.py inside my_package:</h1>
  
  <pre><code>def create_app(test_config=None):
     app = Flask(__name__, instance_relative_config=True)
     app.config.from_object('config')
  
     @app.route('/route1', methods=['POST', 'PUT'])
     def route1():
        if request.method == 'POST':
          # route logic...
          pass
        elif request.method == 'PUT':
          # route logic...
          pass
  
     @app.route('/route2', methods=['POST'])
     def route2():
        if request.method == 'POST':
          # route logic...
          pass
  
     return app
  </code></pre>
  
  <h1>server.py file, outside my_package:</h1>
  
  <pre><code>import my_package
  from waitress import serve
  
  serve(my_package.create_app(), host='0.0.0.0', port=9600)
  </code></pre>
  
  <p>Expected: API requests will only run once per call.</p>
  
  <p>Actual: API requests are being run twice per call.</p>