Skip to content

Commit 5941695

Browse files
committed
Configure gunicorn.
1 parent cbe1788 commit 5941695

File tree

17 files changed

+329
-311
lines changed

17 files changed

+329
-311
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,6 @@ venv.bak/
106106
# OSX
107107
.DS_Store
108108

109-
# PyCharm
109+
# IDEs
110110
.idea
111+
.vscode

Makefile

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,35 @@ all help:
2525

2626
env: $(VIRTUAL_ENV)
2727

28+
2829
$(VIRTUAL_ENV):
2930
if [ ! -d $(VIRTUAL_ENV) ]; then \
3031
echo "Creating Python virtual env in \`${VIRTUAL_ENV}\`"; \
31-
python3 -m venv $(VIRTUAL_ENV); \
32+
python3 -m venv $(VIRTUAL_ENV) \
33+
source $(VIRTUAL_ENV)/bin/activate;
34+
else \
35+
source $(VIRTUAL_ENV)/bin/activate;
3236
fi
3337

38+
3439
.PHONY: run
3540
run: env
36-
$(LOCAL_PYTHON) -m gunicorn -w 4 wsgi:app
37-
38-
39-
requirements: .requirements.txt
40-
env: ./.venv/bin/activate
41-
41+
$(LOCAL_PYTHON) -m gunicorn --config=gunicorn.conf.py
4242

43-
.requirements.txt: requirements.txt
44-
$(shell . .venv/bin/activate && pip install -r requirements.txt)
4543

4644
.PHONY: install
4745
install: env
4846
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \
4947
$(LOCAL_PYTHON) -m pip install -r requirements.txt && \
5048
echo Installed dependencies in \`${VIRTUAL_ENV}\`;
5149

50+
5251
.PHONY: deploy
5352
deploy:
5453
make install && \
5554
make run
5655

56+
5757
.PHONY: update
5858
update: env
5959
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \
@@ -67,6 +67,7 @@ format: env
6767
isort --multi-line=3 . && \
6868
black .
6969

70+
7071
.PHONY: lint
7172
lint:
7273
flake8 . --count \
@@ -75,20 +76,21 @@ lint:
7576
--show-source \
7677
--statistics
7778

79+
7880
.PHONY: clean
7981
clean:
80-
find . -name 'poetry.lock' -delete
81-
find . -name '.coverage' -delete
82-
find . -name '**/*.pyc' -delete
83-
find . -name 'poetry.lock' -delete
84-
find . -name '*.log' -delete
85-
find . -name '.DS_Store' -delete
86-
find . -wholename '**/*.pyc' -delete
87-
find . -wholename '**/*.html' -delete
88-
find . -type d -wholename '**/__pycache__/' -exec rm -rf {} \;
89-
find . -type d -wholename '.venv' -exec rm -rf {} \;
90-
find . -type d -wholename '.pytest_cache' -exec rm -rf {} \;
91-
find . -type d -wholename '**/.pytest_cache' -exec rm -rf {} \;
92-
find . -type d -wholename '**/*.log' -exec rm -rf {} \;
93-
find . -type d -wholename './.reports/*' -exec rm -rf {} \;
94-
find . -type d -wholename '**/.webassets-cache/' -exec rm -rf {} \;
82+
find . -name '.coverage' -delete && \
83+
find . -name '*.pyc' -delete \
84+
find . -name '__pycache__' -delete \
85+
find . -name 'poetry.lock' -delete \
86+
find . -name '*.log' -delete \
87+
find . -name '.DS_Store' -delete \
88+
find . -wholename '**/*.pyc' -delete && \
89+
find . -wholename '**/*.html' -delete && \
90+
find . -type d -wholename '__pycache__' -exec rm -rf {} + && \
91+
find . -type d -wholename '.venv' -exec rm -rf {} + && \
92+
find . -type d -wholename '.pytest_cache' -exec rm -rf {} + && \
93+
find . -type d -wholename '**/.pytest_cache' -exec rm -rf {} + && \
94+
find . -type d -wholename '**/*.log' -exec rm -rf {} + && \
95+
find . -type d -wholename './.reports/*' -exec rm -rf {} + && \
96+
find . -type d -wholename '**/.webassets-cache' -exec rm -rf {};

config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""App configuration."""
2+
23
from os import environ, path
34

45
from dotenv import load_dotenv

flask_wtforms_tutorial/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Initialize app."""
2+
23
from flask import Flask
34

45

flask_wtforms_tutorial/forms.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
11
"""Form object declaration."""
2+
23
from flask_wtf import FlaskForm, RecaptchaField
3-
from wtforms import (
4-
DateField,
5-
PasswordField,
6-
SelectField,
7-
StringField,
8-
SubmitField,
9-
TextAreaField,
10-
)
4+
from wtforms import DateField, PasswordField, SelectField, StringField, SubmitField, TextAreaField
115
from wtforms.validators import URL, DataRequired, Email, EqualTo, Length
126

137

148
class ContactForm(FlaskForm):
159
"""Contact form."""
1610

1711
name = StringField("Name", [DataRequired()])
18-
email = StringField(
19-
"Email", [Email(message="Not a valid email address."), DataRequired()]
20-
)
21-
body = TextAreaField(
22-
"Message", [DataRequired(), Length(min=4, message="Your message is too short.")]
23-
)
12+
email = StringField("Email", [Email(message="Not a valid email address."), DataRequired()])
13+
body = TextAreaField("Message", [DataRequired(), Length(min=4, message="Your message is too short.")])
2414
submit = SubmitField("Submit")
2515

2616

2717
class SignupForm(FlaskForm):
2818
"""Sign up for a user account."""
2919

30-
email = StringField(
31-
"Email", [Email(message="Not a valid email address."), DataRequired()]
32-
)
20+
email = StringField("Email", [Email(message="Not a valid email address."), DataRequired()])
3321
password = PasswordField(
3422
"Password",
3523
[DataRequired(message="Please enter a password.")],
3624
)
37-
confirmPassword = PasswordField(
38-
"Repeat Password", [EqualTo(password, message="Passwords must match.")]
39-
)
25+
confirmPassword = PasswordField("Repeat Password", [EqualTo(password, message="Passwords must match.")])
4026
title = SelectField(
4127
"Title",
4228
[DataRequired()],

flask_wtforms_tutorial/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Routing."""
2+
23
from flask import current_app as app
34
from flask import redirect, render_template, url_for
45

flask_wtforms_tutorial/static/css/forms.css

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ form {
1818
@media(max-width: 500px) {
1919
.container {
2020
padding: 0;
21+
margin: 0;
22+
width: 100%;
2123
}
2224
}
2325

@@ -38,14 +40,16 @@ form {
3840
}
3941

4042
label {
41-
font-size: .9em;
43+
font-family: 'Poppins', sans-serif;
4244
color: #5f6988;
4345
margin-bottom: 3px;
4446
display: block;
45-
font-weight: 300;
47+
font-weight: 400;
4648
}
4749

48-
input, textarea, select {
50+
input,
51+
textarea,
52+
select {
4953
padding: 10px 13px;
5054
margin-bottom: 15px;
5155
width: -webkit-fill-available;
@@ -83,36 +87,35 @@ input[type="text"]:hover,
8387
input[type="password"]:hover,
8488
textarea:hover,
8589
select:hover {
86-
border-color: #5eb9d7;
90+
border-color: #0297f6;
8791
background: #d9f6ff;
8892
}
8993

9094
input[type="text"]:focus,
9195
input[type="password"]:focus,
9296
textarea:focus {
9397
background: white;
94-
border-color: #5eb9d7;
98+
border-color: #0297f6;
9599
box-shadow: unset;
96100
}
97101

98102
input[type="submit"],
99103
button {
100-
background: #5eb9d7;
104+
background: #0297f6;
101105
color: white;
102106
border-radius: 2px;
103107
margin-top: 15px;
104108
font-weight: 400;
105-
border: 1px solid #5eb9d7;
106-
line-height: 1;
109+
padding: 10px 13px;
110+
border: 1px solid #0297f6;
107111
transition: all .3s ease-out;
108112
}
109113

110114
input[type="submit"]:hover,
111115
button:hover {
112116
cursor: pointer;
113117
background: white;
114-
color: #5eb9d7;
115-
padding: 13px !important;
118+
color: #0297f6;
116119
}
117120

118121
.success-wrapper {
@@ -123,19 +126,19 @@ button:hover {
123126
}
124127

125128
.errors {
126-
list-style: none;
127-
margin: -15px 0 20px;
128-
font-size: .8em;
129-
text-align: left;
130-
width: -webkit-fill-available;
131-
width: -moz-available;
132-
background: #fae7ea;
133-
padding: 9px 15px;
134-
border-radius: 0 0 3px 3px;
135-
border-top: 0;
136-
border: 1px solid #e1c5c5;
137-
color: #8d7575;
138-
height: fit-content;
129+
list-style: none;
130+
margin: -15px 0 20px;
131+
font-size: .8em;
132+
text-align: left;
133+
width: -webkit-fill-available;
134+
width: -moz-available;
135+
background: #fae7ea;
136+
padding: 9px 15px;
137+
border-radius: 0 0 3px 3px;
138+
border-top: 0;
139+
border: 1px solid #e1c5c5;
140+
color: #8d7575;
141+
height: fit-content;
139142
}
140143

141144
.error {

flask_wtforms_tutorial/static/css/home.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
text-transform: uppercase;
99
margin-bottom: 10px;
1010
display: block;
11-
color: #3979a4;
11+
color: #0297f6;
1212
}
1313

1414
.home-template h1 {
@@ -17,4 +17,4 @@
1717

1818
.home-template i {
1919
font-size: .9em;
20-
}
20+
}
Loading
Loading

flask_wtforms_tutorial/static/css/success.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
}
1919

2020
button {
21-
background: #5eb9d7;
21+
background: #0297f6;
2222
color: white;
2323
border-radius: 2px;
2424
margin-top: 15px;
2525
font-weight: 400;
26-
border: 1px solid #5eb9d7;
26+
border: 1px solid #0297f6;
2727
line-height: 1;
2828
transition: all .3s ease-out;
2929
padding: 10px 15px;
@@ -33,5 +33,5 @@ button {
3333
button:hover {
3434
cursor: pointer;
3535
background: white;
36-
color: #5eb9d7;
36+
color: #0297f6;
3737
}

0 commit comments

Comments
 (0)