Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 455
rablentain Avatar asked Jan 16 '16 08:01

rablentain


People also ask

How do you run a Flask migration?

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.

What is Flask_migrate?

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.

How do I create a migration repository in Flask?

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.


1 Answers

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))
like image 77
davidism Avatar answered Nov 02 '22 17:11

davidism