Skip to content

Commit 44e16ad

Browse files
committed
Upgrade to Python3.10.
1 parent 9bfe1c2 commit 44e16ad

File tree

10 files changed

+444
-427
lines changed

10 files changed

+444
-427
lines changed

.env.example

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
ENVIRONMENT=development
2-
FLASK_APP=wsgi.py
1+
ENVIRONMENT=production
2+
FLASK_APP=main.py
33
FLASK_DEBUG=True
4-
SECRET_KEY=yoursecretkey
5-
SQLALCHEMY_DATABASE_URI=mysql+pymysql://myuser:mypassword@host.example.com:1234/mydatabase
4+
SECRET_KEY=HGFDGGUFCJHDJCWDGCKDWWW
5+
66
REDIS_URI=redis://:password@host.com:1234
7-
COMPRESSOR_DEBUG=True
7+
8+
SQLALCHEMY_DATABASE_URI=mysql+pymysql://myuser:mypassword@host.example.com:1234/mydatabase
9+
SQLALCHEMY_TRACK_MODIFICATIONS=False
10+
SQLALCHEMY_CA_CERTS="./certificate.crt"
11+
812
ASSETS_DEBUG=False
913
LESS_RUN_IN_DEBUG=False
14+
COMPRESSOR_DEBUG=False
15+
ASSETS_DEBUG=False
16+
LESS_RUN_IN_DEBUG=False

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ venv/
8888
ENV/
8989
env.bak/
9090
venv.bak/
91+
.creds/
9192

9293
# Spyder project settings
9394
.spyderproject

Makefile

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Manage $(PROJECT_NAME). Usage:
77

88
make run - Run $(PROJECT_NAME) locally.
99
make install - Create local virtualenv & install dependencies.
10-
make deploy - Set up project & run locally.
1110
make update - Update dependencies via Poetry and output resulting `requirements.txt`.
1211
make format - Run Python code formatter & sort dependencies.
1312
make lint - Check code formatting with flake8.
@@ -17,44 +16,31 @@ endef
1716
export HELP
1817

1918

20-
.PHONY: run install deploy update format lint clean help
21-
19+
.PHONY: run install update format lint clean help
2220

2321
all help:
2422
@echo "$$HELP"
2523

26-
2724
env: $(VIRTUAL_ENV)
2825

29-
3026
$(VIRTUAL_ENV):
3127
if [ ! -d $(VIRTUAL_ENV) ]; then \
3228
echo "Creating Python virtual env in \`${VIRTUAL_ENV}\`"; \
3329
python3 -m venv $(VIRTUAL_ENV); \
3430
fi
3531

36-
3732
.PHONY: run
3833
run: env
3934
export LESS_BIN=$(shell which lessc) && \
40-
uwsgi --http 127.0.0.1:8082 --master --module wsgi:app --processes 4 --threads 2
41-
35+
$(LOCAL_PYTHON) -m main
4236

4337
.PHONY: install
4438
install: env
4539
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \
46-
$(LOCAL_PYTHON) -m pip install --no-cache-dir uwsgi && \
4740
$(LOCAL_PYTHON) -m pip install -r requirements.txt && \
4841
npm i -g less && \
4942
echo Installed dependencies in \`${VIRTUAL_ENV}\`;
5043

51-
52-
.PHONY: deploy
53-
deploy:
54-
make install
55-
make run
56-
57-
5844
.PHONY: test
5945
test: env
6046
$(LOCAL_PYTHON) -m \
@@ -63,22 +49,18 @@ test: env
6349
coverage html --title='Coverage Report' -d .reports && \
6450
open .reports/index.html
6551

66-
6752
.PHONY: update
6853
update: env
6954
$(LOCAL_PYTHON) -m pip install --upgrade pip setuptools wheel && \
70-
$(LOCAL_PYTHON) -m pip install --no-cache-dir uwsgi && \
7155
poetry update && \
7256
poetry export -f requirements.txt --output requirements.txt --without-hashes && \
7357
echo Installed dependencies in \`${VIRTUAL_ENV}\`;
7458

75-
7659
.PHONY: format
7760
format: env
7861
$(LOCAL_PYTHON) -m isort --multi-line=3 . && \
7962
$(LOCAL_PYTHON) -m black .
8063

81-
8264
.PHONY: lint
8365
lint: env
8466
$(LOCAL_PYTHON) -m flake8 . --count \
@@ -87,7 +69,6 @@ lint: env
8769
--show-source \
8870
--statistics
8971

90-
9172
.PHONY: clean
9273
clean:
9374
find . -name 'poetry.lock' -delete && \
@@ -98,12 +79,12 @@ clean:
9879
find . -name '*.log' -delete \
9980
find . -name '.DS_Store' -delete \
10081
find . -wholename '**/*.pyc' -delete && \
101-
find . -wholename '*.html' -delete && \
82+
find . -wholename '**/*.html' -delete && \
10283
find . -type d -wholename '__pycache__' -exec rm -rf {} + && \
10384
find . -type d -wholename '.venv' -exec rm -rf {} + && \
10485
find . -type d -wholename '.pytest_cache' -exec rm -rf {} + && \
10586
find . -type d -wholename '**/.pytest_cache' -exec rm -rf {} + && \
106-
find . -type d -wholename './logs/*' -exec rm -rf {} + && \
87+
find . -type d -wholename '**/*.log' -exec rm -rf {} + && \
10788
find . -type d -wholename './.reports/*' -exec rm -rf {} + && \
10889
find . -type d -wholename '**/.webassets-cache' -exec rm -rf {} +
10990

README.md

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

3-
![Python](https://img.shields.io/badge/Python-v^3.9-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
4-
![Flask](https://img.shields.io/badge/Flask-v^2.2.2-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
3+
![Python](https://img.shields.io/badge/Python-v^3.10-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
4+
![Flask](https://img.shields.io/badge/Flask-v^2.3.3-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
55
![Flask-Login](https://img.shields.io/badge/Flask--Login-v0.6.2-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
6-
![Flask-Session](https://img.shields.io/badge/Flask--Session-v0.4.0-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
7-
![Redis](https://img.shields.io/badge/Redis-v4.4.2-red.svg?longCache=true&style=flat-square&logo=redis&logoColor=white&colorA=4c566a&colorB=bf616a)
6+
![Flask-Session](https://img.shields.io/badge/Flask--Session-v0.5.0-blue.svg?longCache=true&logo=flask&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
7+
![Redis](https://img.shields.io/badge/Redis-v5.0.0-red.svg?longCache=true&style=flat-square&logo=redis&logoColor=white&colorA=4c566a&colorB=bf616a)
88
![GitHub Last Commit](https://img.shields.io/github/last-commit/google/skia.svg?style=flat-square&colorA=4c566a&colorB=a3be8c&logo=GitHub)
99
[![GitHub Issues](https://img.shields.io/github/issues/hackersandslackers/flask-session-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-session-tutorial/issues)
1010
[![GitHub Stars](https://img.shields.io/github/stars/hackersandslackers/flask-session-tutorial.svg?style=flat-square&colorA=4c566a&logo=GitHub&colorB=ebcb8b)](https://github.com/hackersandslackers/flask-session-tutorial/stargazers)
@@ -22,7 +22,7 @@ Get set up locally in two steps:
2222

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

25-
* `FLASK_APP`: Entry point of your application; should be `wsgi.py`.
25+
* `FLASK_APP`: Entry point of your application; should be `main.py`.
2626
* `FLASK_DEBUG`: Toggle debug mode on (`True`) or off (`False`).
2727
* `SECRET_KEY`: Randomly generated string of characters used to encrypt your app's data.
2828
* `SQLALCHEMY_DATABASE_URI`: Connection URI of a SQL database.
@@ -46,4 +46,4 @@ make deploy
4646

4747
-----
4848

49-
**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.
49+
**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.

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ class Config:
3535
# Flask-SQLAlchemy
3636
SQLALCHEMY_DATABASE_URI = environ.get("SQLALCHEMY_DATABASE_URI")
3737
SQLALCHEMY_TRACK_MODIFICATIONS = False
38-
SQLALCHEMY_ECHO = True
38+
SQLALCHEMY_ECHO = False

flask_session_tutorial/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class User(UserMixin, db.Model):
99
"""Model for user accounts."""
1010

1111
__tablename__ = "flasksession-users"
12+
1213
id = db.Column(db.Integer, primary_key=True)
1314
name = db.Column(db.String(200), nullable=False, unique=False)
1415
email = db.Column(db.String(40), unique=True, nullable=False)
@@ -26,4 +27,4 @@ def check_password(self, password):
2627
return check_password_hash(self.password, password)
2728

2829
def __repr__(self):
29-
return "<User {}>".format(self.name)
30+
return f"<User id={self.id}, name={self.name}, email={self.email}>"

wsgi.py renamed to main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
app = create_app()
55

6-
if __name__ == "__wsgi__":
7-
app.run(host="127.0.0.1")
6+
if __name__ == "__main__":
7+
app.run(host="127.0.0.1", port=8082, load_dotenv=True)

0 commit comments

Comments
 (0)