https://github.com/billy0402/flask-tutorial
A learning project from the book 'Flask Web Development'.
https://github.com/billy0402/flask-tutorial
course flask python restful-api
Last synced: about 2 months ago
JSON representation
A learning project from the book 'Flask Web Development'.
- Host: GitHub
- URL: https://github.com/billy0402/flask-tutorial
- Owner: billy0402
- Created: 2019-09-28T03:01:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-02T04:18:32.000Z (about 5 years ago)
- Last Synced: 2025-10-07T13:37:33.510Z (9 months ago)
- Topics: course, flask, python, restful-api
- Language: Python
- Homepage:
- Size: 77.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [flask-tutorial](https://github.com/miguelgrinberg/flasky)
## environment
- [macOS 10.15.7](https://www.apple.com/tw/macos/catalina/)
- [PyCharm 2020.3.3](https://www.jetbrains.com/pycharm/)
- [Python 3.8.7](https://www.python.org/)
- [Flask 1.1.2](https://flask.palletsprojects.com/en/1.1.x/)
## environment variable
```shell
$ export FLASK_APP=main.py
$ export FLASK_CONFIG=development
$ export MAIL_USERNAME=
$ export MAIL_PASSWORD=
$ export FLASKY_ADMIN=
```
## command
```shell
# run server
$ flask run
# open shell
$ flask shell
# run unit test
$ flask test
```
## database migration
```shell
# init
$ flask db init
# make migration
$ flask db migrate -m "initial migration"
# migrate
$ flask db upgrade
$ flask db downgrade
$ flask db stamp
```
## load data
```python
from app.models import Role
Role.insert.roles
```
## fake data
```python
from app import fake
fake.users()
fake.posts()
```
## heroku
```shell
# 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
```shell
$ 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
```