Commits

Kenneth Love  committed 66f021d

initial

  • Participants

Comments (0)

Files changed (3)

+from flask import Flask, render_template
+import redis
+app = Flask(__name__)
+app.debug = True
+
+r = redis.Redis()
+
+@app.route('/')
+def index():
+    keys = r.keys()
+    return render_template('index.html', keys=keys)
+
+@app.route('/key/<key>')
+def key(key):
+    if r.type(key) == 'hash':
+        output = r.hgetall(key)
+    else:
+        output = r.get(key)
+    return render_template('key.html', key=key, output=output)
+
+if __name__ == '__main__':
+    app.run()

File templates/index.html

+<!DOCTYPE HTML>
+<html>
+<head>
+	<meta http-equiv="content-type" content="text/html; charset=utf-8">
+
+	<title>Redbeard</title>
+	
+</head>
+<body>
+	<h1>Red fuckin' beard</h1>
+	<ul>
+		{% for key in keys %}
+		<li><a href="{{ url_for('key', key=key) }}">{{ key }}</a></li>
+		{% endfor %}
+	</ul>
+</body>
+</html>

File templates/key.html

+<!DOCTYPE HTML>
+<html>
+<head>
+	<meta http-equiv="content-type" content="text/html; charset=utf-8">
+
+	<title>Redbeard</title>
+	
+</head>
+<body>
+	<h1>{{ key }}</h1>
+	<pre>{{ output }}</pre>
+	<a href="{{ url_for('index') }}">back</a>
+</body>
+</html>