Nginx/Flask/Redis Sample Compose
Signed-off-by: ajeetraina <ajeetraina@gmail.com>
This commit is contained in:
16
nginx-flask-redis/web/app/app.py
Normal file
16
nginx-flask-redis/web/app/app.py
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
import os
|
||||
import socket
|
||||
|
||||
from flask import Flask
|
||||
from redis import Redis
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
redis = Redis(host=os.environ.get('REDIS_HOST', 'redis'), port=6379)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def hello():
|
||||
redis.incr('hits')
|
||||
return 'Hi Docker! You have seen %s times and your system is %s.\n' % (redis.get('hits'),socket.gethostname())
|
16
nginx-flask-redis/web/app/config.py
Normal file
16
nginx-flask-redis/web/app/config.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import multiprocessing
|
||||
import os
|
||||
|
||||
from distutils.util import strtobool
|
||||
|
||||
|
||||
bind = os.getenv('WEB_BIND', '0.0.0.0:8000')
|
||||
accesslog = '-'
|
||||
access_log_format = "%(h)s %(l)s %(u)s %(t)s '%(r)s' %(s)s %(b)s '%(f)s' '%(a)s' in %(D)sµs" # noqa: E501
|
||||
|
||||
workers = int(os.getenv('WEB_CONCURRENCY', multiprocessing.cpu_count() * 2))
|
||||
threads = int(os.getenv('PYTHON_MAX_THREADS', 1))
|
||||
|
||||
reload = bool(strtobool(os.getenv('WEB_RELOAD', 'false')))
|
Reference in New Issue
Block a user