Skip to content

Commit 639fcc7

Browse files
committed
Fix broken image, minor updates.
1 parent e85d0ba commit 639fcc7

File tree

10 files changed

+409
-349
lines changed

10 files changed

+409
-349
lines changed
File renamed without changes.

Makefile

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,75 @@
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
56
Manage $(PROJECTNAME). Usage:
67

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.
8+
make run - Run $(PROJECT_NAME).
9+
make install - Create virtual env, & install dependencies.
10+
make update - Update pip dependencies via Poetry and output requirements.txt.
1011
make format - Format code with Python's `Black` library.
12+
make lint - Check code formatting with flake8.
1113
make clean - Remove cached files and lock files.
1214
endef
1315
export HELP
1416

15-
.PHONY: run deploy update format clean help
17+
.PHONY: run install update format lint clean help
1618

1719

18-
requirements: .requirements.txt
19-
env: .venv/bin/activate
20-
21-
22-
.requirements.txt: requirements.txt
23-
$(shell . .venv/bin/activate && pip install -r requirements.txt)
20+
env: .venv/bin/python3
2421

2522

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

2926

27+
.PHONY: install
28+
install:
29+
if [ ! -d "./.venv" ]; then python3 -m venv $(VIRTUAL_ENVIRONMENT); fi
30+
. .venv/bin/activate
31+
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel
32+
$(LOCAL_PYTHON) -m pip install -r requirements.txt
33+
34+
3035
.PHONY: run
3136
run: env
3237
$(shell . .venv/bin/activate && flask run)
3338

3439

35-
.PHONY: deploy
36-
deploy:
37-
$(shell . ./deploy.sh)
38-
39-
4040
.PHONY: update
41-
update: env
42-
.venv/bin/python3 -m pip install -U pip
41+
update:
42+
if [ ! -d "./.venv" ]; then python3 -m venv $(VIRTUAL_ENVIRONMENT); fi
43+
.venv/bin/python3 -m pip install --upgrade pip setuptools wheel
4344
poetry update
4445
poetry export -f requirements.txt --output requirements.txt --without-hashes
4546

4647

4748
.PHONY: format
4849
format: env
49-
$(shell . .venv/bin/activate && isort ./)
50-
$(shell . .venv/bin/activate && black ./)
50+
isort --multi-line=3 .
51+
black .
52+
53+
54+
.PHONY: lint
55+
lint:
56+
flake8 . --count \
57+
--select=E9,F63,F7,F82 \
58+
--exclude .git,.github,__pycache__,.pytest_cache,.venv,logs,creds,.venv,docs,logs \
59+
--show-source \
60+
--statistics
5161

5262

5363
.PHONY: clean
5464
clean:
5565
find . -name '*.pyc' -delete
5666
find . -name '__pycache__' -delete
5767
find . -name 'poetry.lock' -delete
58-
find . -name 'Pipefile.lock' -delete
68+
find . -name 'Pipefile.lock' -delete
69+
find . -name '*.log' -delete
70+
find . -wholename 'logs/*.json' -delete
71+
find . -wholename '.pytest_cache' -delete
72+
find . -wholename '**/.pytest_cache' -delete
73+
find . -wholename './logs/*.json' -delete
74+
find . -wholename '.webassets-cache/*' -delete
75+
find . -wholename './logs' -delete

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![GitHub Stars](https://img.shields.io/github/stars/hackersandslackers/flask-blueprint-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-blueprint-tutorial/stargazers)
99
[![GitHub Forks](https://img.shields.io/github/forks/hackersandslackers/flask-blueprint-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-blueprint-tutorial/network)
1010

11-
![Flask Blueprint Tutorial](https://github.com/hackersandslackers/flask-blueprint-tutorial/blob/master/.github/flaskblueprints-3@2x.jpg?raw=true)
11+
![Flask Blueprint Tutorial](./.github/flaskblueprints@2x.jpg?raw=true)
1212

1313
Structure your Flask apps in a scalable and intelligent way using Blueprints.
1414

config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ class Config:
2424
TEMPLATES_FOLDER = "templates"
2525
COMPRESSOR_DEBUG = True
2626

27+
# Datadog
28+
DD_SERVICE = environ.get("DD_SERVICE")
29+
2730
# API
2831
BEST_BUY_API_KEY = environ.get("BEST_BUY_API_KEY")

flask_blueprint_tutorial/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Initialize Flask app."""
2+
from ddtrace import patch_all
23
from flask import Flask
34
from flask_assets import Environment
4-
from ddtrace import patch_all
55

6+
from config import Config
67

7-
patch_all()
8+
if Config.FLASK_ENV == "production" and Config.DD_SERVICE:
9+
patch_all()
810

911

1012
def init_app():

flask_blueprint_tutorial/assets.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,37 @@ def compile_static_assets(assets):
77
"""Create stylesheet bundles."""
88
assets.auto_build = True
99
assets.debug = False
10-
common_less_bundle = Bundle(
10+
common_style_bundle = Bundle(
1111
"src/less/*.less",
1212
filters="less,cssmin",
1313
output="dist/css/style.css",
1414
extra={"rel": "stylesheet/less"},
1515
)
16-
home_less_bundle = Bundle(
16+
home_style_bundle = Bundle(
1717
"home_bp/less/home.less",
1818
filters="less,cssmin",
1919
output="dist/css/home.css",
2020
extra={"rel": "stylesheet/less"},
2121
)
22-
profile_less_bundle = Bundle(
22+
profile_style_bundle = Bundle(
2323
"profile_bp/less/profile.less",
2424
filters="less,cssmin",
2525
output="dist/css/profile.css",
2626
extra={"rel": "stylesheet/less"},
2727
)
28-
product_less_bundle = Bundle(
28+
product_style_bundle = Bundle(
2929
"products_bp/less/products.less",
3030
filters="less,cssmin",
3131
output="dist/css/products.css",
3232
extra={"rel": "stylesheet/less"},
3333
)
34-
assets.register("common_less_bundle", common_less_bundle)
35-
assets.register("home_less_bundle", home_less_bundle)
36-
assets.register("profile_less_bundle", profile_less_bundle)
37-
assets.register("product_less_bundle", product_less_bundle)
34+
assets.register("common_style_bundle", common_style_bundle)
35+
assets.register("home_style_bundle", home_style_bundle)
36+
assets.register("profile_style_bundle", profile_style_bundle)
37+
assets.register("product_style_bundle", product_style_bundle)
3838
if app.config["FLASK_ENV"] == "development":
39-
common_less_bundle.build()
40-
home_less_bundle.build()
41-
profile_less_bundle.build()
42-
product_less_bundle.build()
39+
common_style_bundle.build()
40+
home_style_bundle.build()
41+
profile_style_bundle.build()
42+
product_style_bundle.build()
4343
return assets

flask_blueprint_tutorial/templates/layout.jinja2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<meta name="twitter:site" content="@hackersslackers"/>
2222
<meta name="twitter:creator" content="@toddrbirchard"/>
2323
<meta name="twitter:card" content="summary_large_image"/>
24-
<meta name="twitter:image" content="https://hackersandslackers-cdn.storage.googleapis.com/2020/05/flaskblueprints-3@2x.jpg"/>
25-
<meta property="og:image" content="https://hackersandslackers-cdn.storage.googleapis.com/2020/05/flaskblueprints-3@2x.jpg"/>
24+
<meta name="twitter:image" content="https://cdn.hackersandslackers.com/2021/08/_retina/flaskblueprints.jpg"/>
25+
<meta property="og:image" content="https://cdn.hackersandslackers.com/2021/08/_retina/flaskblueprints.jpg"/>
2626
<meta property="og:image:width" content="1000"/>
2727
<meta property="og:image:height" content="523"/>
2828
<link href="https://fonts.googleapis.com/css?family=Poppins:200,300,400,500" rel="stylesheet">

0 commit comments

Comments
 (0)