From fd710175584c09556355e078677fd7a4a7623d12 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Tue, 8 Feb 2022 06:19:27 -0300 Subject: [PATCH 01/11] Updated python version to 3.9.10 --- runtime.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.txt b/runtime.txt index aefcfbe..ed36cfc 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.7.5 +python-3.9.10 From 580022ea5e7baa390c831ba5ad9cfa940e33b311 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Tue, 8 Feb 2022 06:37:55 -0300 Subject: [PATCH 02/11] Added correct uri for Heroku when using latest SQLAlchemy versions --- app.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index abb6205..cb98648 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,4 @@ -import os +import os, re from flask import Flask from flask_restful import Api @@ -13,7 +13,11 @@ app.config['DEBUG'] = True -app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', 'sqlite:///data.db') +# https://help.heroku.com/ZKNTJQSK/why-is-sqlalchemy-1-4-x-not-connecting-to-heroku-postgres +uri = os.getenv("DATABASE_URL") +if uri.startswith("postgres://"): + uri = uri.replace("postgres://", "postgresql://", 1) + app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.secret_key = 'jose' api = Api(app) From aeb8e8c7ac5e38dd90ad4daf226aef2219cab1e0 Mon Sep 17 00:00:00 2001 From: Leonardo U Spairani Date: Sun, 10 Apr 2022 10:32:47 -0300 Subject: [PATCH 03/11] Testing on python 3.10 --- runtime.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.txt b/runtime.txt index ed36cfc..30e81e3 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.9.10 +python-3.10.3 From cdb9d3201168901e351a8da7caa2d76c34570458 Mon Sep 17 00:00:00 2001 From: Leonardo U Spairani Date: Sun, 10 Apr 2022 10:38:20 -0300 Subject: [PATCH 04/11] Rollback to python 3.9 --- runtime.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.txt b/runtime.txt index 30e81e3..8fdd907 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.10.3 +python-3.9 From 0f26509fa43cf8ca558bd67a3d3ccebe7a8bde8c Mon Sep 17 00:00:00 2001 From: Leonardo U Spairani Date: Sun, 10 Apr 2022 10:39:00 -0300 Subject: [PATCH 05/11] Update runtime.txt --- runtime.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.txt b/runtime.txt index 8fdd907..5402961 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.9 +python-3.9.12 From 47228e0c72e2f5cb9b53019a30a42fe912e15a62 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sun, 10 Apr 2022 11:00:40 -0300 Subject: [PATCH 06/11] Updated to hmac compare_digest --- security.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security.py b/security.py index 6d1eb72..70b42ac 100644 --- a/security.py +++ b/security.py @@ -1,9 +1,9 @@ -from werkzeug.security import safe_str_cmp +from hmac import compare_digest from models.user import UserModel def authenticate(username, password): user = UserModel.find_by_username(username) - if user and safe_str_cmp(user.password, password): + if user and compare_digest(user.password, password): return user def identity(payload): From 0b54ab0d47b6077c712258d270aebbe6f7840b4c Mon Sep 17 00:00:00 2001 From: Leonardo U Spairani Date: Sun, 10 Apr 2022 11:03:16 -0300 Subject: [PATCH 07/11] Testing python 3.10 --- runtime.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.txt b/runtime.txt index 5402961..30e81e3 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.9.12 +python-3.10.3 From dbe22ea73cbb2e4ffba9cfafd832bb9e82520ed9 Mon Sep 17 00:00:00 2001 From: Leonardo U Spairani Date: Sun, 10 Apr 2022 11:08:33 -0300 Subject: [PATCH 08/11] Rollback to python 3.9 --- runtime.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.txt b/runtime.txt index 30e81e3..5402961 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.10.3 +python-3.9.12 From 4d50db4f8abd7de9398a92afa2f742930128ecff Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sun, 10 Apr 2022 11:22:20 -0300 Subject: [PATCH 09/11] Removed unnecesary code --- app.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app.py b/app.py index cb98648..ee40765 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,4 @@ -import os, re +import os from flask import Flask from flask_restful import Api @@ -13,11 +13,6 @@ app.config['DEBUG'] = True -# https://help.heroku.com/ZKNTJQSK/why-is-sqlalchemy-1-4-x-not-connecting-to-heroku-postgres -uri = os.getenv("DATABASE_URL") -if uri.startswith("postgres://"): - uri = uri.replace("postgres://", "postgresql://", 1) - app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.secret_key = 'jose' api = Api(app) From 2652b7f40fed64c252ba52e36e306581843e49eb Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sun, 10 Apr 2022 11:28:29 -0300 Subject: [PATCH 10/11] Added db uri --- app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app.py b/app.py index ee40765..abb6205 100644 --- a/app.py +++ b/app.py @@ -13,6 +13,7 @@ app.config['DEBUG'] = True +app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', 'sqlite:///data.db') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.secret_key = 'jose' api = Api(app) From 3cbdda12aae564193883975cc0ecc68ce20cea3e Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sun, 10 Apr 2022 11:33:58 -0300 Subject: [PATCH 11/11] Added code to solve sqlalchemy.exc.NoSuchModuleError --- app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index abb6205..a0eb398 100644 --- a/app.py +++ b/app.py @@ -13,7 +13,11 @@ app.config['DEBUG'] = True -app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', 'sqlite:///data.db') +uri = os.environ.get('DATABASE_URL', 'sqlite:///data.db') +if uri.startswith("postgres://"): + uri = uri.replace("postgres://", "postgresql://", 1) + +app.config['SQLALCHEMY_DATABASE_URI'] = uri app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.secret_key = 'jose' api = Api(app)