From 5930c92a8094e501bf2a3e9add18cb2eb4024044 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 12 Apr 2022 12:01:01 +0300 Subject: Don't create db engine for static files There is no need to create a database engine for requests for static files like CSS files and javascript files. This commit checks for and skips the creation of the engine for such requests. --- wqflask/wqflask/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 1dd654df..2138146c 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -109,7 +109,7 @@ logger = utility.logger.getLogger(__name__) @app.before_request def connect_db(): db = getattr(g, '_database', None) - if db is None: + if request.endpoint not in ("static", "js") and db is None: g.db = g._database = sqlalchemy.create_engine( SQL_URI, encoding="latin1") -- cgit v1.2.3