From 9b79a3796b03d8cf38e2342fcbcb641cb06c05ba Mon Sep 17 00:00:00 2001 From: finn Date: Tue, 30 Jul 2024 12:58:32 +0000 Subject: [PATCH] set up wsgi/flask option in backend --- backend/Dockerfile | 2 +- backend/app.py | 8 +------- backend/requirements.txt | 1 + compose.yaml | 2 ++ 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index fc602f1..6e581ef 100755 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -8,7 +8,7 @@ RUN target=/root/.cache/pip \ COPY . . -ENV FLASK_APP giapp.py +ENV FLASK_APP app.py # This might be scary to leave on #ENV FLASK_ENV development diff --git a/backend/app.py b/backend/app.py index 8705f70..4aab203 100755 --- a/backend/app.py +++ b/backend/app.py @@ -11,12 +11,9 @@ class DBManager: #printf("DEBUG:" + envuser + envpass) self.connection = mysql.connector.connect( user=envuser, - #user=user, password=envpass, - #password=password, host=host, # name of the mysql service as set in the docker compose file database=database - #auth_plugin='mysql_native_password' ) self.cursor = self.connection.cursor() @@ -46,9 +43,6 @@ def listBlog(): rec = conn.query_titles() response = '' - ict = '' - arg1 = '' - arg2 = '' for c in rec: response = response + '
Log: ' + c + '
' @@ -58,7 +52,7 @@ def listBlog(): response = response + '
Delta: ' + dtFormatted + '
' return response -@server.route('/args-test', methods=['GET']) +@server.route('/inconsequential-auth', methods=['GET']) def listArgs(): good_token_i = str(os.getenv("TOKEN_I")) diff --git a/backend/requirements.txt b/backend/requirements.txt index b723ac1..c189106 100755 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -1,3 +1,4 @@ Flask==3.0.3 Werkzeug==3.0.3 mysql-connector-python +pyuwsgi diff --git a/compose.yaml b/compose.yaml index 5ee2e1e..27b9454 100644 --- a/compose.yaml +++ b/compose.yaml @@ -27,6 +27,8 @@ services: context: backend target: builder restart: always + # Comment following line to use flask (1worker, dev), uncomment to use uwsgi (wsgi) + command: ["uwsgi", "--http", "0.0.0.0:8000", "--master", "-p", "4", "-w", "app:server"] environment: - MYSQL_USER=flasku #- MYSQL_PASSWORD=flaskp