From 3030c1358d3c13e4d3c67d4ecccbef515cc01cb1 Mon Sep 17 00:00:00 2001 From: ajeetraina Date: Sat, 12 Mar 2022 11:22:09 +0530 Subject: [PATCH] Fixed formatting changes Signed-off-by: ajeetraina --- flask-redis/README.md | 5 ++--- flask-redis/app.py | 5 ++--- nginx-node-redis | 1 - nginx-nodejs-redis/README.md | 13 +++++-------- nginx-nodejs-redis/docker-compose.yml | 2 +- 5 files changed, 10 insertions(+), 16 deletions(-) delete mode 160000 nginx-node-redis diff --git a/flask-redis/README.md b/flask-redis/README.md index 6e4ffda..b7f0414 100644 --- a/flask-redis/README.md +++ b/flask-redis/README.md @@ -1,6 +1,6 @@ ## Compose sample application -### Python/Flask application built using Docker Compose +### Python/Flask application using a Redis database Project structure: @@ -16,7 +16,6 @@ Project structure: [_docker-compose.yml_](docker-compose.yml) ``` -version: '2' services: redis: image: redislabs/redismod @@ -61,7 +60,7 @@ flask-redis-web-1 "/bin/sh -c 'python …" web running After the application starts, navigate to `http://localhost:5000` in your web browser or run: ``` $ curl localhost:5000 - +This webpage has been viewed 2 time(s) ``` ## Monitoring Redis keys diff --git a/flask-redis/app.py b/flask-redis/app.py index 04aaf44..873a3cf 100644 --- a/flask-redis/app.py +++ b/flask-redis/app.py @@ -1,4 +1,3 @@ -# compose_flask/app.py from flask import Flask from redis import Redis @@ -8,8 +7,8 @@ redis = Redis(host='redis', port=6379) @app.route('/') def hello(): redis.incr('hits') - return 'This webpage has been viewed %s time(s).' % redis.get('hits') - + counter = str(redis.get('hits'),'utf-8') + return "This webpage has been viewed "+counter+" time(s)" if __name__ == "__main__": app.run(host="0.0.0.0", debug=True) diff --git a/nginx-node-redis b/nginx-node-redis deleted file mode 160000 index d92de2c..0000000 --- a/nginx-node-redis +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d92de2c2e1119d094df3910788e6f9e595042cf7 diff --git a/nginx-nodejs-redis/README.md b/nginx-nodejs-redis/README.md index 545f21a..3c0fe10 100644 --- a/nginx-nodejs-redis/README.md +++ b/nginx-nodejs-redis/README.md @@ -1,3 +1,4 @@ +## Compose sample application ## Node.js application with Nginx proxy and Redis database @@ -26,10 +27,8 @@ Project structure: [_docker-compose.yml_](docker-compose.yml) ``` -version: '3.9' -services: - redis: - image: 'redis:alpine' +redis: + image: 'redislabs/redismod' ports: - '6379:6379' web1: @@ -50,8 +49,8 @@ services: - web1 - web2 ``` -The compose file defines an application with four services `redis`, `web`, `web1` and `web2`. -When deploying the application, docker-compose maps port 80 of the web service container to port 80 of the host as specified in the file. +The compose file defines an application with four services `redis`, `nginx`, `web1` and `web2`. +When deploying the application, docker-compose maps port 80 of the nginx service container to port 80 of the host as specified in the file. > ℹ️ **_INFO_** @@ -61,8 +60,6 @@ When deploying the application, docker-compose maps port 80 of the web service c ``` $ docker-compose up -d -``` -``` Creating nginx-nodejs-redis_redis_1 ... done Creating nginx-nodejs-redis_web1_1 ... done Creating nginx-nodejs-redis_web2_1 ... done diff --git a/nginx-nodejs-redis/docker-compose.yml b/nginx-nodejs-redis/docker-compose.yml index 8e0f3f4..4d08922 100644 --- a/nginx-nodejs-redis/docker-compose.yml +++ b/nginx-nodejs-redis/docker-compose.yml @@ -1,7 +1,7 @@ services: redis: - image: 'redis:alpine' + image: 'redislabs/redismod' ports: - '6379:6379' web1: