pythonflaskwaitress

Python Flask waitress-serve command-line call argument?


I have the following simple py file below. It works fine if I type python damn.py, but it says not to use it as production server. I have installed waitress. In my case, what exactly should the argument in the " " be? I have tried waitress-serve --call "damn:create_app", but it id not work.

damn.py

from flask import Flask

api = Flask(__name__)

@api.route('/test', methods=['GET'])
def test():
  return "Hello world"

if __name__ == '__main__':
    api.run()

Solution

  • waitress-serve --help
    

    lists the following on the --call flag:

    Call the given object to get the WSGI application.

    You have no create_app function that returns the WSGI application. You don't need the call flag since you're not using the Application Factory pattern.

    You can just do:

    waitress-serve "damn:api"