Skip to content

Commit 9d114b6

Browse files
committed
Update dependencies; Makefile.
1 parent eb87d4a commit 9d114b6

File tree

7 files changed

+284
-257
lines changed

7 files changed

+284
-257
lines changed

Makefile

+47-22
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
SRCPATH := $(CURDIR)
2-
PROJECTNAME := $(shell basename $(CURDIR))
1+
PROJECT_NAME := $(shell basename $CURDIR)
2+
VIRTUAL_ENVIRONMENT := $(CURDIR)/.venv
3+
LOCAL_PYTHON := $(VIRTUAL_ENVIRONMENT)/bin/python3
34

45
define HELP
5-
Manage $(PROJECTNAME). Usage:
6-
7-
make run - Run $(PROJECTNAME).
8-
make deploy - Install requirements and run app for the first time.
9-
make update - Update pip dependencies via Python Poetry.
10-
make format - Format code with Python's `Black` library.
11-
make lint - Check code formatting with flake8
6+
Manage $(PROJECT_NAME). Usage:
7+
8+
make run - Run $(PROJECT_NAME).
9+
make install - Create virtual env, install dependencies, and run project.
10+
make deploy - Install and run script by running `make install` and `make run` in succession.
11+
make update - Update pip dependencies via Poetry and export output to requirements.txt.
12+
make format - Format code with Pythons `Black` library.
13+
make lint - Check code formatting with `flake8`.
1214
make clean - Remove cached files and lock files.
15+
1316
endef
1417
export HELP
1518

16-
.PHONY: run deploy update format lint clean help
1719

20+
.PHONY: run install deploy update format lint clean help
1821

1922
requirements: .requirements.txt
20-
env: .venv/bin/activate
23+
env: ./.venv/bin/activate
2124

2225

2326
.requirements.txt: requirements.txt
@@ -30,35 +33,57 @@ all help:
3033

3134
.PHONY: run
3235
run: env
33-
$(shell . .venv/bin/activate && flask run)
36+
flask run
37+
38+
39+
.PHONY: install
40+
install:
41+
if [ ! -d "./.venv" ]; then python3 -m venv $(VIRTUAL_ENVIRONMENT); fi
42+
. .venv/bin/activate
43+
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel
44+
$(LOCAL_PYTHON) -m pip install -r requirements.txt
3445

3546

3647
.PHONY: deploy
3748
deploy:
38-
$(shell . ./deploy.sh)
49+
make install
50+
make run
3951

4052

4153
.PHONY: update
42-
update: env
43-
.venv/bin/python3 -m pip install -U pip
54+
update:
55+
if [ ! -d "./.venv" ]; then python3 -m venv $(VIRTUAL_ENVIRONMENT); fi
56+
.venv/bin/python3 -m pip install --upgrade pip setuptools wheel
4457
poetry update
4558
poetry export -f requirements.txt --output requirements.txt --without-hashes
4659

4760

4861
.PHONY: format
4962
format: env
50-
$(shell . .venv/bin/activate && isort ./)
51-
$(shell . .venv/bin/activate && black ./)
63+
isort --multi-line=3 .
64+
black .
65+
66+
67+
.PHONY: lint
68+
lint:
69+
flake8 . --count \
70+
--select=E9,F63,F7,F82 \
71+
--exclude .git,.github,__pycache__,.pytest_cache,.venv,logs,creds,.venv,docs,logs \
72+
--show-source \
73+
--statistics
5274

5375

5476
.PHONY: clean
5577
clean:
5678
find . -name '*.pyc' -delete
5779
find . -name '__pycache__' -delete
5880
find . -name 'poetry.lock' -delete
59-
find . -name 'Pipefile.lock' -delete
60-
find . -name 'logs/*.json' -delete
6181
find . -name '*.log' -delete
62-
find . -name '*/.pytest_cache' -delete
63-
find . -name '*/logs/*.json' -delete
64-
rm -rf tests/.pytest_cache
82+
find . -name '.DS_Store' -delete
83+
find . -wholename 'logs/*.json' -delete
84+
find . -wholename '.pytest_cache' -delete
85+
find . -wholename '**/.pytest_cache' -delete
86+
find . -wholename './logs/*.json' -delete
87+
find . -wholename './logs' -delete
88+
find . -wholename '*.html' -delete
89+
find . -wholename '**/.webassets-cache' -delete

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Flask-WTF Tutorial
22

33
![Python](https://img.shields.io/badge/Python-v^3.8-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
4-
![Flask](https://img.shields.io/badge/Flask-v1.1.1-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
5-
![Flask-WTF](https://img.shields.io/badge/Flask--WTF-v0.14.2-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
4+
![Flask](https://img.shields.io/badge/Flask-v2.1.1-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
5+
![Flask-WTF](https://img.shields.io/badge/Flask--WTF-v1.0.1-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
66
![GitHub Last Commit](https://img.shields.io/github/last-commit/google/skia.svg?style=flat-square&colorA=4c566a&colorB=a3be8c&logo=GitHub)
77
[![GitHub Issues](https://img.shields.io/github/issues/hackersandslackers/flask-wtform-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-wtform-tutorial/issues)
88
[![GitHub Stars](https://img.shields.io/github/stars/hackersandslackers/flask-wtform-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-wtform-tutorial/stargazers)
99
[![GitHub Forks](https://img.shields.io/github/forks/hackersandslackers/flask-wtform-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-wtform-tutorial/network)
1010

1111
![Flask-WTF Tutorial](https://github.com/hackersandslackers/flask-wtform-tutorial/blob/master/.github/[email protected]?raw=true)
1212

13-
**Tutorial**: https://hackersandslackers.com/flask-wtforms-forms/
14-
15-
**Demo**: https://flaskwtf.hackersandslackers.app/
16-
13+
Handle user input in your Flask app by creating forms with the Flask-WTForm library.
1714

15+
* **Tutorial**: https://hackersandslackers.com/flask-wtforms-forms/
16+
* **Demo**: https://flaskwtf.hackersandslackers.app/
17+
=
1818
# Getting Started
1919

2020
Get set up locally:

flask_wtforms_tutorial/forms.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ class ContactForm(FlaskForm):
1616

1717
name = StringField("Name", [DataRequired()])
1818
email = StringField(
19-
"Email",
20-
[Email(message="Not a valid email address."), DataRequired()]
19+
"Email", [Email(message="Not a valid email address."), DataRequired()]
2120
)
2221
body = TextAreaField(
23-
"Message",
24-
[DataRequired(), Length(min=4, message="Your message is too short.")]
22+
"Message", [DataRequired(), Length(min=4, message="Your message is too short.")]
2523
)
2624
submit = SubmitField("Submit")
2725

@@ -30,16 +28,14 @@ class SignupForm(FlaskForm):
3028
"""Sign up for a user account."""
3129

3230
email = StringField(
33-
"Email",
34-
[Email(message="Not a valid email address."), DataRequired()]
31+
"Email", [Email(message="Not a valid email address."), DataRequired()]
3532
)
3633
password = PasswordField(
3734
"Password",
3835
[DataRequired(message="Please enter a password.")],
3936
)
4037
confirmPassword = PasswordField(
41-
"Repeat Password",
42-
[EqualTo(password, message="Passwords must match.")]
38+
"Repeat Password", [EqualTo(password, message="Passwords must match.")]
4339
)
4440
title = SelectField(
4541
"Title",

flask_wtforms_tutorial/routes.py

+4-15
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
def home():
1010
"""Landing page."""
1111
return render_template(
12-
"index.jinja2",
13-
template="home-template",
14-
title="Flask-WTF tutorial"
12+
"index.jinja2", template="home-template", title="Flask-WTF tutorial"
1513
)
1614

1715

@@ -22,10 +20,7 @@ def contact():
2220
if form.validate_on_submit():
2321
return redirect(url_for("success"))
2422
return render_template(
25-
"contact.jinja2",
26-
form=form,
27-
template="form-template",
28-
title="Contact Form"
23+
"contact.jinja2", form=form, template="form-template", title="Contact Form"
2924
)
3025

3126

@@ -36,17 +31,11 @@ def signup():
3631
if form.validate_on_submit():
3732
return redirect(url_for("success"))
3833
return render_template(
39-
"signup.jinja2",
40-
form=form,
41-
template="form-template",
42-
title="Signup Form"
34+
"signup.jinja2", form=form, template="form-template", title="Signup Form"
4335
)
4436

4537

4638
@app.route("/success", methods=["GET", "POST"])
4739
def success():
4840
"""Generic success page upon form submission."""
49-
return render_template(
50-
"success.jinja2",
51-
template="success-template"
52-
)
41+
return render_template("success.jinja2", template="success-template")

0 commit comments

Comments
 (0)