0duaansa commited on
Commit
07a2fc7
·
verified ·
1 Parent(s): 32223c6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, jsonify
2
+ import redis
3
+
4
+ app = Flask(__name__)
5
+ r = redis.Redis(host='localhost', port=6379, decode_responses=True)
6
+
7
+ @app.route('/')
8
+ def home():
9
+ return "Redis is running! Access the API at /info."
10
+
11
+ @app.route('/info')
12
+ def info():
13
+ try:
14
+ info = r.info()
15
+ return jsonify(info)
16
+ except Exception as e:
17
+ return jsonify({"error": str(e)}), 500
18
+
19
+ if __name__ == '__main__':
20
+ app.run(host='0.0.0.0', port=5000)
21
+