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?
In order to run the migrations initialize Alembic: $ python manage.py db init Creating directory /flask-by-example/migrations ... done Creating directory /flask-by-example/migrations/versions ... done Generating /flask-by-example/migrations/alembic.
Flask-Migrate is an extension that handles SQLAlchemy database migrations for Flask applications using Alembic. The database operations are provided as command-line arguments under the flask db command.
To first set up your migrations directory, we can run flask db init . This creates a new migration repository; in so doing, this command creates a couple of folders and files in our project root where our migrations will live. We only need to do this once.
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With