title: Use waitress as a production server for Flask
body: <p>I have written an application in Python/Flask which I need to deploy in production on a Windows Server(unfortunately). I came across a suggestion to use Waitress. It was a simple modification to make the web app use waitress, but my issues remain unsolved.</p>
  
  <p>To server using waitress I have modified the code as below(just a basic example)</p>
  
  <pre><code>from flask import Flask
  from waitress import serve
  app = Flask(__name__)
  
  @app.route('/')
  def hello():
      return 'Hello World!'
  
  if __name__ == '__main__':
      # app.run()
      serve(app, host='0.0.0.0', port=8000)
  </code></pre>
  
  <p>Now I can run this from the command prompt via(same as without waitress)</p>
  
  <pre><code>python myapp.py
  </code></pre>
  
  <p>But I cannot use this in production. </p>
  
  <ul>
  <li>How do I make sure that the server keeps running in case someone closes the cmd prompt.</li>
  <li>How to make sure when the server is rebooted, the webapp comes up automatically without a user having to login and launch the app again.</li>
  </ul>
  
  <p>If these two basic issues are not solvable then I wonder why waitress claims to be a production ready server :)</p>