Skip to content

Starting Flask

Timothy Ko edited this page Jul 20, 2018 · 3 revisions

Starting Flask

Running the development server for Docker is different. Look at the Second section for instructions.

Using the Regular Setup

To run the server, make sure you are in the root directory. Then, startup the virtual environment and run the server:

$ pipenv shell  # startup virtual environment
(flask-boilerplate-_rcP-Rlt) bash-3.2$ python manage.py runserver

If you are using pipenv, you may also run commands without being inside your virtual environment:

$ pipenv run python manage.py runserver # pipenv run [command]

The API should be at http://127.0.0.1:5000/ for you to experience its beauty. If that link doesn't work, try http://localhost:5000 instead.

Using Docker

If you setup this boilerplate using Docker, you must run the Docker Containers itself, not the development server. To start your Postgres and your flask api:

$ docker-compose start

If you haven't built the images, then:

$ docker-compose up -d

-d runs it in the background.

To stop them:

$ docker-compose stop

To view your logs for the api:

$ docker-compose logs app

If you need to rebuild your containers, delete the previous containers and rebuild

$ docker-compose rm -f
$ docker-compose up -d

NOTE: Be careful to not run multiple containers of the same image. Check with docker ps and use docker-compose stop to stop all the containers if you are running multiple containers and restart.