Skip to content

A learning project from the book 'Flask Web Development'.

Notifications You must be signed in to change notification settings

billy0402/flask-tutorial

Repository files navigation

environment

environment variable

$ export FLASK_APP=main.py
$ export FLASK_CONFIG=development
$ export MAIL_USERNAME=<your email address>
$ export MAIL_PASSWORD=<your email password>
$ export FLASKY_ADMIN=<your email address>

command

# run server
$ flask run

# open shell
$ flask shell

# run unit test
$ flask test

database migration

# init
$ flask db init

# make migration
$ flask db migrate -m "initial migration"

# migrate
$ flask db upgrade
$ flask db downgrade
$ flask db stamp

load data

from app.models import Role

Role.insert.roles

fake data

from app import fake

fake.users()
fake.posts()

heroku

# local test
$ heroku local:run flask deploy
$ heroku local
$ heroku local web=3

# production deploy
$ heroku maintenance:on
$ git push heroku master
$ heroku run flask deploy
$ heroku restart
$ heroku maintenance:off

docker

$ docker build -t flasky:latest .
$ docker run --name postgres -d \
    -e POSTGRES_PASSWORD=postgres \
    -e POSTGRES_DB="flasky" \
    postgres:latest
$ docker run --name flasky -d -p 8000:5000 \
    --link postgres:dbserver \
    -e MAIL_USERNAME=${your_email_address} \
    -e MAIL_PASSWORD=${your_email_password} \
    -e FLASKY_ADMIN=${your_email_address} \
    -e DATABASE_URL="postgresql://postgres:postgres@dbserver/flasky" \
    flasky:latest

$ docker-compose up -d --build

About

A learning project from the book 'Flask Web Development'.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published