Skip to content

Commit b02521d

Browse files
committed
Migrate to gunicorn.
1 parent 3902b3e commit b02521d

File tree

20 files changed

+94
-230
lines changed

20 files changed

+94
-230
lines changed

.env.example

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
FLASK_APP=main.py
2-
FLASK_ENV=production
1+
ENVIRONMENT=production
2+
FLASK_DEBUG=false
33
SECRET_KEY=randomstringofcharacters
4+
45
LESS_BIN=/usr/local/bin/lessc
56
ASSETS_DEBUG=False
67
LESS_RUN_IN_DEBUG=False
7-
COMPRESSOR_DEBUG=True
8+
COMPRESSOR_DEBUG=False

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@ $(VIRTUAL_ENV):
3030
python3 -m venv $(VIRTUAL_ENV); \
3131
fi
3232

33-
.PHONY: dev
34-
dev: env
35-
$(LOCAL_PYTHON) -m main --reload
36-
3733
.PHONY: run
3834
run: env
39-
$(LOCAL_PYTHON) -m main
35+
$(LOCAL_PYTHON) -m gunicorn -w 4 wsgi:app
4036

4137
.PHONY: install
4238
install: env

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Structure your Flask apps in a scalable and intelligent way using Blueprints.
1414

1515
* **Tutorial**: [https://hackersandslackers.com/flask-blueprints/](https://hackersandslackers.com/flask-blueprints/)
16-
* **Demo**: [https://flaskblueprints.hackersandslackers.app/](https://flaskblueprints.hackersandslackers.app/)
16+
* **Demo**: [https://flaskblueprints.hackersandslackers.app/](https://flaskblueprints.hackersandslackers.com/)
1717

1818
## Getting Started
1919

@@ -23,8 +23,8 @@ Get set up locally in two steps:
2323

2424
Replace the values in **.env.example** with your values and rename this file to **.env**:
2525

26-
* `FLASK_APP`: Entry point of your application; should be `main.py`.
27-
* `FLASK_ENV`: The environment in which to run your application; either `development` or `production`.
26+
* `ENVIRONMENT`: The environment in which to run your application (either `development` or `production`).
27+
* `FLASK_APP`: Entry point of your application; should be `wsgi.py`.
2828
* `SECRET_KEY`: Randomly generated string of characters used to encrypt your app's data.
2929
* `LESS_BIN` *(optional for static assets)*: Path to your local LESS installation via `which lessc`.
3030
* `ASSETS_DEBUG` *(optional)*: Debug asset creation and bundling in `development`.

config.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@
1010
class Config:
1111
"""Configuration from environment variables."""
1212

13+
# General Config\
14+
ENVIRONMENTS = environ.get("ENVIRONMENT")
15+
16+
# Flask Config
1317
SECRET_KEY = environ.get("SECRET_KEY")
14-
FLASK_ENV = environ.get("FLASK_ENV")
15-
FLASK_APP = "main.py"
18+
FLASK_DEBUG = environ.get("FLASK_DEBUG")
19+
FLASK_APP = "wsgi.py"
1620

1721
# Flask-Assets
1822
LESS_BIN = environ.get("LESS_BIN")
19-
ASSETS_DEBUG = True
20-
LESS_RUN_IN_DEBUG = True
23+
ASSETS_DEBUG = False
24+
LESS_RUN_IN_DEBUG = False
2125

2226
# Static Assets
2327
STATIC_FOLDER = "static"
2428
TEMPLATES_FOLDER = "templates"
25-
COMPRESSOR_DEBUG = True
26-
27-
# Datadog
28-
DD_SERVICE = environ.get("DD_SERVICE")
29+
COMPRESSOR_DEBUG = False
2930

3031
# Hardcoded data
3132
PRODUCT_DATA_FILEPATH = f"{BASE_DIR}/data/products.json"

flask_blueprint_tutorial/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from flask_assets import Environment
44

55

6-
def flask_app():
6+
def create_app():
77
"""Create Flask application."""
88
app = Flask(__name__, instance_relative_config=False)
99
app.config.from_object("config.Config")

flask_blueprint_tutorial/assets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def compile_static_assets(assets):
3535
assets.register("home_style_bundle", home_style_bundle)
3636
assets.register("profile_style_bundle", profile_style_bundle)
3737
assets.register("product_style_bundle", product_style_bundle)
38-
if app.config["FLASK_ENV"] == "development":
38+
if app.config["ENVIRONMENTS"] == "development":
3939
common_style_bundle.build()
4040
home_style_bundle.build()
4141
profile_style_bundle.build()

flask_blueprint_tutorial/static/dist/css/style.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
12.5 KB
Loading
12.5 KB
Loading

0 commit comments

Comments
 (0)