def searchkeys(search_str: str): # Get the count. count = request.args.get("count", 999) # Get the page page = request.args.get("page", 1) # Pass the search string to the database. results = pgp.search_through_keys(search_str, page=page, count=count) # Serialize the data into a JSON list of key ids. # Yes, this can hammer the server on shitty clients when they search. # But redis can pick up a lot of that slack. return json.dumps( {"count": results.total, "ids": [item.key_fp_id for item in results.items]} ), 200 if results.total else 404, {"Content-Type": "application/json"}
def search(): if 'keyid' in request.args: page = request.args.get("page", 1) try: page = int(page) except: page = 1 # Pass a simple list of KeyInfos to the renderer, allowing the template to do the hard work. keys = pgp.search_through_keys(request.args.get("keyid", "0x12345678"), page=page) if not keys.total: page = 0 return render_template("search.html", search=request.args.get('keyid'), keys=keys.items, keyinfo=KeyInfo, page=page, maxpages=keys.pages, num_keys=keys.total) else: return render_template("search.html")
def pkssearch(rargs): keys = pgp.search_through_keys(rargs.get("search")) if not keys.total: return "No keys found", 404 else: return format_pks(keys), 200, {"X-HKP-Results-Count": keys.total, "Content-Type": "application/x-pgp-search"}