|
4 years ago | |
---|---|---|
app | 6 years ago | |
migrations | 6 years ago | |
.flaskenv | 6 years ago | |
.gitignore | 6 years ago | |
README.md | 5 years ago | |
config.py | 6 years ago | |
requirements.txt | 4 years ago | |
run.py | 6 years ago |
This repo contains a simple flasks application. The application provides a simple web GUI with routes and a template.
pip install -r requirements.txt
The following can be added to a .env
file in the foot of this directory as well
APP_ENVIRONMENT="PROD"
SECRET_KEY="myverysecretkey"
DATABASE_URL="sqlite:///app.db"
export FLASK_APP=run.py
app/models.py
flask db migrate -m "<class/table> table"
flask db upgrade
flask db upgrade
u = User(username='john', email='john@example.com')
u.set_password('password')
db.session.add(u)
u = User(username='susan', email='susan@example.com')
u.set_password('password')
db.session.add(u)
db.session.commit()
# get user
u = User.query.get(1)
u
#<User john>
# get all users in reverse alphabetical order
User.query.order_by(User.username.desc()).all()
#[<User susan>, <User john>]
users = User.query.all()
for u in users:
db.session.delete(u)
db.session.commit()