From 45c263602bd6f96d87946f32b0ca1dc6242bf6c6 Mon Sep 17 00:00:00 2001 From: Kiril Kovachev Date: Mon, 14 Oct 2024 12:33:37 +0100 Subject: [PATCH] Expand search to handle results, search submission --- kanken_online/search.py | 11 ++++++++++- kanken_online/templates/search/search.html | 11 ++++++++++- kanken_online/templates/search/search_results.html | 11 +++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 kanken_online/templates/search/search_results.html diff --git a/kanken_online/search.py b/kanken_online/search.py index 8d84120..40bcf31 100644 --- a/kanken_online/search.py +++ b/kanken_online/search.py @@ -1,7 +1,16 @@ -from flask import Blueprint, render_template +from flask import Blueprint, render_template, request blueprint = Blueprint("search", __name__, url_prefix="/search") +def search_results(args: dict): + class renderable: + def render(self): + return "ok" + results = [renderable(), renderable()] # Do something with args + return render_template("search/search_results.html", results=results, value=args["keywords"]) + @blueprint.route("/") def search_page(): + if request.args: + return search_results(request.args) return render_template("search/search.html") diff --git a/kanken_online/templates/search/search.html b/kanken_online/templates/search/search.html index 8bc3e69..c0aae21 100644 --- a/kanken_online/templates/search/search.html +++ b/kanken_online/templates/search/search.html @@ -5,5 +5,14 @@ {% endblock %} {% block content %} - +
+ + + + + + +
+ {% block results %} + {% endblock %} {% endblock %} \ No newline at end of file diff --git a/kanken_online/templates/search/search_results.html b/kanken_online/templates/search/search_results.html new file mode 100644 index 0000000..85132f1 --- /dev/null +++ b/kanken_online/templates/search/search_results.html @@ -0,0 +1,11 @@ +{% extends 'search/search.html' %} + +{% block results %} + +{% for result in results %} +
+ {{result.render()}} +
+{% endfor %} + +{% endblock%} \ No newline at end of file