26 lines
620 B
Python
26 lines
620 B
Python
from flask import Flask
|
|
from flask_redis import Redis
|
|
|
|
# make sure redis (container) is running and accessible
|
|
|
|
# see https://flask-and-redis.readthedocs.io/en/latest/
|
|
# see https://github.com/andymccurdy/redis-py
|
|
|
|
app = Flask(__name__)
|
|
app.config["REDIS_HOST"] = "localhost"
|
|
app.config["REDIS_PORT"] = 6379
|
|
redis = Redis(app)
|
|
|
|
|
|
@app.route("/")
|
|
def home_page():
|
|
redis.set('tl1', 'sending change red -> green <br>')
|
|
redis.append('tl1', 'sending change green -> red <br>')
|
|
redis.set('v1', 'receiving vel 100 km/h <br>')
|
|
|
|
return redis.get('tl1') + redis.get('v1')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.run()
|