Test / app.py
0duaansa's picture
Create app.py
07a2fc7 verified
raw
history blame contribute delete
462 Bytes
from flask import Flask, jsonify
import redis
app = Flask(__name__)
r = redis.Redis(host='localhost', port=6379, decode_responses=True)
@app.route('/')
def home():
return "Redis is running! Access the API at /info."
@app.route('/info')
def info():
try:
info = r.info()
return jsonify(info)
except Exception as e:
return jsonify({"error": str(e)}), 500
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)