Skip to content

Commit 671cdcb

Browse files
committed
Update dependencies; update Python version; resolve image in README.
1 parent fd335ca commit 671cdcb

File tree

19 files changed

+599
-429
lines changed

19 files changed

+599
-429
lines changed

.github/img/flask-jinja@2x.jpg

108 KB
Loading

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ __pycache__
134134

135135
# PyCharm
136136
.idea
137+
.vscode
137138

138139
# Virtual environment
139140
.venv/

Makefile

Lines changed: 74 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,98 @@
1-
SRCPATH := $(CURDIR)
2-
PROJECTNAME := $(shell basename $(CURDIR))
1+
PROJECT_NAME := $(shell basename $CURDIR)
2+
VIRTUAL_ENV := $(CURDIR)/.venv
3+
LOCAL_PYTHON := $(VIRTUAL_ENV)/bin/python3
34

45
define HELP
5-
Manage $(PROJECTNAME). Usage:
6+
Manage $(PROJECT_NAME). Usage:
7+
8+
make run - Run $(PROJECT_NAME) locally.
9+
make install - Create local virtualenv & install dependencies.
10+
make deploy - Set up project & run locally.
11+
make update - Update dependencies via Poetry and output resulting `requirements.txt`.
12+
make format - Run Python code formatter & sort dependencies.
13+
make lint - Check code formatting with flake8.
14+
make clean - Remove extraneous compiled files, caches, logs, etc.
615

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 clean - Remove cached files and lock files.
1216
endef
1317
export HELP
1418

15-
.PHONY: run restart deploy update clean help
16-
17-
18-
requirements: .requirements.txt
19-
20-
21-
.requirements.txt: requirements.txt
22-
$(shell . .venv/bin/activate && pip install -r requirements.txt)
2319

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

2522
all help:
2623
@echo "$$HELP"
2724

25+
env: $(VIRTUAL_ENV)
2826

29-
.PHONY: run
30-
run:
31-
$(shell . .venv/bin/activate && python3 wsgi.py)
27+
$(VIRTUAL_ENV):
28+
if [ ! -d $(VIRTUAL_ENV) ]; then \
29+
echo "Creating Python virtual env in \`${VIRTUAL_ENV}\`"; \
30+
python3 -m venv $(VIRTUAL_ENV); \
31+
fi
32+
33+
.PHONY: dev
34+
dev: env
35+
$(LOCAL_PYTHON) -m main --reload
3236

37+
.PHONY: run
38+
run: env
39+
$(LOCAL_PYTHON) -m main
40+
41+
.PHONY: install
42+
install: env
43+
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \
44+
LDFLAGS="-L$(/opt/homebrew/bin/brew --prefix openssl)/lib -L$(/opt/homebrew/bin/brew --prefix re2)/lib" && \
45+
CPPFLAGS="-I$(/opt/homebrew/bin/brew --prefix openssl)/include -I$(/opt/homebrew/bin/brew --prefix re2)/include" && \
46+
GRPC_BUILD_WITH_BORING_SSL_ASM="" && \
47+
GRPC_PYTHON_BUILD_SYSTEM_RE2=true && \
48+
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true && \
49+
GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true && \
50+
pip install grpcio && \
51+
$(LOCAL_PYTHON) -m pip install -r requirements.txt && \
52+
echo Installed dependencies in \`${VIRTUAL_ENV}\`;
3353

3454
.PHONY: deploy
3555
deploy:
36-
$(shell . ./deploy.sh)
56+
make install && \
57+
make run
3758

59+
.PHONY: test
60+
test: env
61+
$(LOCAL_PYTHON) -m \
62+
coverage run -m pytest -vv \
63+
--disable-pytest-warnings && \
64+
coverage html --title='Coverage Report' -d .reports && \
65+
open .reports/index.html
3866

3967
.PHONY: update
40-
update:
41-
poetry shell && poetry update
42-
pip freeze > requirements.txt
43-
exit
44-
68+
update: env
69+
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \
70+
poetry update && \
71+
poetry export -f requirements.txt --output requirements.txt --without-hashes && \
72+
echo Installed dependencies in \`${VIRTUAL_ENV}\`;
4573

4674
.PHONY: format
47-
format: requirements
48-
$(shell . .venv/bin/activate)
49-
$(shell isort -rc ./)
50-
$(shell black ./)
51-
75+
format: env
76+
$(LOCAL_PYTHON) -m isort --multi-line=3 . && \
77+
$(LOCAL_PYTHON) -m black .
78+
79+
.PHONY: lint
80+
lint: env
81+
$(LOCAL_PYTHON) -m flake8 . --count \
82+
--select=E9,F63,F7,F82 \
83+
--exclude .git,.github,__pycache__,.pytest_cache,.venv,logs,creds,.venv,docs,logs,.reports \
84+
--show-source \
85+
--statistics
5286

5387
.PHONY: clean
5488
clean:
55-
find . -name '*.pyc' -delete
56-
find . -name '__pycache__' -delete
57-
find . -name 'poetry.lock' -delete
58-
find . -name 'Pipefile.lock' -delete
89+
find . -name 'poetry.lock' -delete && \
90+
find . -name '.coverage' -delete && \
91+
find . -name '.Pipfile.lock' -delete && \
92+
find . -wholename '**/*.pyc' -delete && \
93+
find . -type d -wholename '__pycache__' -exec rm -rf {} + && \
94+
find . -type d -wholename './.venv' -exec rm -rf {} + && \
95+
find . -type d -wholename '.pytest_cache' -exec rm -rf {} + && \
96+
find . -type d -wholename '**/.pytest_cache' -exec rm -rf {} + && \
97+
find . -type d -wholename './logs/*.log' -exec rm -rf {} + && \
98+
find . -type d -wholename './.reports/*' -exec rm -rf {} +

Pipfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

Pipfile.lock

Lines changed: 0 additions & 100 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
# Flask Jinja Tutorial
22

3-
![Python](https://img.shields.io/badge/Python-v3.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)
3+
![Python](https://img.shields.io/badge/Python-v3.10-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
4+
![Flask](https://img.shields.io/badge/Flask-v2.3.3-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
55
![GitHub Last Commit](https://img.shields.io/github/last-commit/google/skia.svg?style=flat-square&colorA=4c566a&colorB=a3be8c&logo=GitHub)
66
[![GitHub Issues](https://img.shields.io/github/issues/hackersandslackers/flask-jinja-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-jinja-tutorial/issues)
77
[![GitHub Stars](https://img.shields.io/github/stars/hackersandslackers/flask-jinja-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-jinja-tutorial/stargazers)
88
[![GitHub Forks](https://img.shields.io/github/forks/hackersandslackers/flask-jinja-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-jinja-tutorial/network)
99

10-
![Flask Jinja Tutorial](https://storage.googleapis.com/hackersandslackers-cdn/2019/02/jinja@2x.jpg)
10+
![Flask Jinja Tutorial](.github/img/flask-jinja@2x.jpg)
1111

12-
Source code for the accompanying tutorial found here: https://hackersandslackers.com/flask-jinja-templates/
12+
Source code for the accompanying tutorial found here: [https://hackersandslackers.com/flask-jinja-templates/](https://hackersandslackers.com/flask-jinja-templates/)
1313

1414
## Installation
1515

16-
Get up and running with `make deploy`:
16+
Get up and running with `make run`:
1717

1818
```shell
19-
$ git clone https://github.com/hackersandslackers/flask-assets-tutorial.git
20-
$ cd flask-assets-tutorial
21-
$ make deploy
22-
```
19+
git clone https://github.com/hackersandslackers/flask-assets-tutorial.git
20+
cd flask-assets-tutorial
21+
make run
22+
```
23+
2324
-----
2425

25-
**Hackers and Slackers** tutorials are free of charge. If you found this tutorial helpful, a [small donation](https://www.buymeacoffee.com/hackersslackers) would be greatly appreciated to keep us in business. All proceeds go towards coffee, and all coffee goes towards more content.
26+
**Hackers and Slackers** tutorials are free of charge. If you found this tutorial helpful, a [small donation](https://www.buymeacoffee.com/hackersslackers) would be greatly appreciated to keep us in business. All proceeds go towards coffee, and all coffee goes towards more content.

deploy.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

flask_jinja_tutorial/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ def create_app():
77
app = Flask(__name__, template_folder="templates")
88

99
with app.app_context():
10-
from . import routes
10+
from flask_jinja_tutorial import routes
1111

1212
return app

flask_jinja_tutorial/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def home():
1212
{"name": "Pics", "url": "https://example.com/3"},
1313
]
1414
return render_template(
15-
"home.html",
15+
"home.jinja2",
1616
nav=nav,
1717
title="Jinja Demo Site",
1818
description="Smarter page templates with Flask & Jinja.",
12.3 KB
Loading

0 commit comments

Comments
 (0)