CORS update
This commit is contained in:
parent
cc44699bcf
commit
c15a404098
@ -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)
|
||||
|
@ -4,7 +4,7 @@ WORKDIR /app
|
||||
|
||||
COPY app.py /app/
|
||||
|
||||
RUN pip install flask redis
|
||||
RUN pip install flask redis flask-cors
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
|
@ -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'])
|
||||
|
@ -14,7 +14,7 @@
|
||||
<script>
|
||||
async function updateCounter() {
|
||||
try {
|
||||
const response = await fetch('http://localhost:5001/counter');
|
||||
const response = await fetch('http://172.17.225.171:5001/counter');
|
||||
const data = await response.json();
|
||||
document.getElementById('counter').textContent = data.visits;
|
||||
} catch (error) {
|
||||
|
Loading…
Reference in New Issue
Block a user