awesome-compose/flask-redis/app.py
Milas Bowman b53e4542c9
flask-redis: dev envs support & misc improvements (#265)
(Most of this is almost identical to #263.)

* Docker Desktop Development Environments config
* Use cache volumes for pip
* Downgrade from Python 3.11 _alpha_ -> Python 3.10
* Use port `8000` to avoid conflicts with Airplay on
    macOS for default Flask port `5000`
* Use `SIGINT` to gracefully stop Flask
* Formatting fixes in `compose.yaml`

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-08 16:48:08 +02:00

15 lines
349 B
Python

from flask import Flask
from redis import Redis
app = Flask(__name__)
redis = Redis(host='redis', port=6379)
@app.route('/')
def hello():
redis.incr('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", port=8000, debug=True)