Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return jsonify({
"error": f"Unrecognised sort parameter: {sort_param}"}), 400
sorted_documents = sorted(
matching_documents.items(),
key=lambda doc: doc[1].get(sort_field, ""),
reverse=sort_order_reverse
)
display_documents = sorted_documents
tag_aggregation = search_helpers.get_tag_aggregation(
[doc for (_, doc) in display_documents]
)
req_url = hyperlink.DecodedURL.from_text(request.url)
params = {k: v for k, v in request.args.items()}
try:
params["_message"] = json.loads(params["_message"])
except KeyError:
pass
view_options = viewer.ViewOptions(
list_view=request.args.get("view", self.config.list_view),
tag_view=self.config.tag_view,
expand_document_form=(request.cookies.get('form-collapse__show') == 'true'),
expand_tag_list=(request.cookies.get('tags-collapse__show') == 'true')
)
pagination = Pagination(
page_size=page_size,