--- /dev/null
+from flask import Flask, request, render_template, make_response, Response
+from flask import request
+import hashlib
+import pgpdump
+import glob
+import base64
+
+app = Flask(__name__)
+
+@app.template_filter('base64')
+def base64_filter(arg):
+ return base64.b64encode(arg)
+
+@app.route("/pks/add", methods=['POST'])
+def add():
+ keytext = request.form['keytext']
+ pgp = pgpdump.AsciiData(keytext)
+ fingerprint = pgp.packets().next().fingerprint
+ with open('data/%s.asc' % fingerprint, 'w') as f:
+ f.write(keytext)
+ return Response("OK", mimetype="text/plain")
+
+@app.route('/')
+def index():
+ result = dict()
+ for entry in glob.glob('data/*.asc'):
+ pgp = pgpdump.AsciiData(file(entry).read())
+ uids = []
+ photoids = []
+ subkeys = []
+ public_key = None
+ for packet in pgp.packets():
+ if packet.name == 'Public Key Packet':
+ public_key = packet
+ elif packet.name == 'User ID Packet':
+ uids.append(packet)
+ elif packet.name == 'User Attribute Packet':
+ photoids.append(packet)
+ elif packet.name == 'Public Subkey Packet':
+ subkeys.append(packet)
+ result[public_key.fingerprint] = (public_key, uids, photoids, subkeys)
+ return render_template('index.html', data = result)
+
+@app.route('/download/')
+def download():
+ result = []
+ for entry in glob.glob('data/*.asc'):
+ with open(entry) as f:
+ result.append(f.read())
+
+ return Response('\n'.join(result), mimetype='application/pgp')
+
+
+if __name__ == "__main__":
+ app.run(debug=True, port=11371)
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
+<title></title>
+</head>
+<body>
+<h1>Key listing</h1>
+<p><a href={{ url_for('download') }}>Download Keyring</a></p>
+<table>
+ {% for entry in data %}
+ <tr>
+ <th colspan="2">{{data[entry][1][0].data}} {{data[entry][0].fingerprint}}</th>
+ </tr>
+ <tr>
+ <td rowspan="{{1 + data[entry][1]|length}}">
+ {% if data[entry][2][0] %}
+ <img height="100" src="data:image/{{data[entry][2][0].image_format}};base64,{{data[entry][2][0].image_data|base64}}"/>
+ {% endif %}
+ </td>
+ <td>
+ {{data[entry][0].pub_algorithm_type}}
+ {{data[entry][0].creation_time}}
+ (expires {{data[entry][0].expiration_time}})
+ </td>
+ </tr>
+ {% for uid in data[entry][1] %}
+ <tr>
+ <td>{{uid.data}}</td>
+ </tr>
+ {% endfor %}
+ {% endfor %}
+</table>
+</body>
+</html>