From c15a404098e06bbab2d9b4f0e7adc6ba3aad5bb2 Mon Sep 17 00:00:00 2001 From: shane ubento Date: Wed, 19 Mar 2025 11:41:44 +0100 Subject: [PATCH] CORS update --- z1/README.md | 4 ++++ z1/backend/Dockerfile | 2 +- z1/backend/app.py | 4 +++- z1/web/index.html | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/z1/README.md b/z1/README.md index 92036a7..6366c18 100644 --- a/z1/README.md +++ b/z1/README.md @@ -38,3 +38,7 @@ http://[ip address you copied]:5000 - A default network is created by docker compose for communication between these services - A named volum ('redis_data') ensures Redis data persists across restarts. + +## Cross-Origin Resource Sharing (CORS) + +Since frount end (Apache) diff --git a/z1/backend/Dockerfile b/z1/backend/Dockerfile index 717a23c..be27c94 100644 --- a/z1/backend/Dockerfile +++ b/z1/backend/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /app COPY app.py /app/ -RUN pip install flask redis +RUN pip install flask redis flask-cors EXPOSE 5000 diff --git a/z1/backend/app.py b/z1/backend/app.py index da96927..dbfb451 100644 --- a/z1/backend/app.py +++ b/z1/backend/app.py @@ -1,9 +1,11 @@ from flask import Flask, jsonify +from flask_cors import CORS import redis app = Flask(__name__) +CORS(app) -# Connect to Redis (running in a separate container) +# Connect to Redis (running in a separate container and foldr) redis_client = redis.StrictRedis(host='redis', port=6379, decode_responses=True) @app.route('/counter', methods=['GET']) diff --git a/z1/web/index.html b/z1/web/index.html index 241da34..83fec2a 100644 --- a/z1/web/index.html +++ b/z1/web/index.html @@ -14,7 +14,7 @@