pythonflaskflask-migrateflask-script

Run app from Flask-Migrate manager


I used these lines to start my application:

from app import app
app.run(host='0.0.0.0', port=8080, debug=True)

Using Flask-Migrate, I have this instead:

from app import manager
manager.run()

manager.run does not take the same arguments as app.run, how do I define host and port?


Solution

  • manage.py replaces running the app with python app.py. It is provided by Flask-Script, not Flask-Migrate which just adds commands to it. Use the runserver command it supplies to run the dev server. You can pass the host and port to that command:

    python manage.py runserver -h localhost -p 8080 -d
    

    or you can override the defaults when configuring the manager:

    from flask_script import Manager, Server
    manager = Manager()
    manager.add_command('runserver', Server(host='localhost', port=8080, debug=True))