mirror of
https://github.com/adulau/abstract-key-server.git
synced 2024-12-22 00:36:03 +00:00
chg: [aks] HKP improvement (still WiP)
This commit is contained in:
parent
1c2369c85e
commit
d1ea3c958b
1 changed files with 6 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
from flask import Flask, request, abort
|
from flask import Flask, request, abort, Response
|
||||||
import configparser
|
import configparser
|
||||||
import redis
|
import redis
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ def index():
|
||||||
|
|
||||||
@app.route('/pks/lookup')
|
@app.route('/pks/lookup')
|
||||||
def pks():
|
def pks():
|
||||||
|
if (request.headers.get('Content-Type') is None) or (request.headers.get('ContentType') == 'text/plain') or (request.headers.get('ContentType') == 'application/pgp-keys'):
|
||||||
|
machinereadable = True
|
||||||
|
else:
|
||||||
|
machinereadable = False
|
||||||
op = request.args.get('op').lower()
|
op = request.args.get('op').lower()
|
||||||
if not (op == 'get' or op == 'index'):
|
if not (op == 'get' or op == 'index'):
|
||||||
abort(501)
|
abort(501)
|
||||||
|
@ -27,7 +31,7 @@ def pks():
|
||||||
if op == 'get' and search.lower().startswith('0x'):
|
if op == 'get' and search.lower().startswith('0x'):
|
||||||
print('Get for {}'.format(search))
|
print('Get for {}'.format(search))
|
||||||
if backend.exists('k:{}'.format(search.lower()[2:])):
|
if backend.exists('k:{}'.format(search.lower()[2:])):
|
||||||
return '{}'.format(backend.get('k:{}'.format(search.lower()[2:])))
|
return Response('{}'.format(backend.get('k:{}'.format(search.lower()[2:]))), mimetype='application/pgp-keys')
|
||||||
if op == 'index' and search.lower():
|
if op == 'index' and search.lower():
|
||||||
print('Searching for {}'.format(search))
|
print('Searching for {}'.format(search))
|
||||||
ret = backend.scan(0, 'ue:*{}'.format(search), count=100)
|
ret = backend.scan(0, 'ue:*{}'.format(search), count=100)
|
||||||
|
|
Loading…
Reference in a new issue