diff --git a/indexer.py b/indexer.py index 6165b79..1d38bb0 100644 --- a/indexer.py +++ b/indexer.py @@ -31,7 +31,15 @@ def create(): def search(): global strings print(strings) - return render_template("result.html", results=request.args.get("q", ""), strings=strings, language="english", categories=settings["categories"]) + connection = sqlite3.connect("torrentdb.sqlite") + c = connection.cursor() + term = request.args.get("q", "") + terms = term.split(" ") + terms = list(map(lambda x: "%" + x + "%", terms)) + search = " AND ".join(["name LIKE (?)"] * len(terms)) + c.execute("SELECT fileid, name FROM torrents WHERE " + search, terms) + results = c.fetchall() + return render_template("result.html", results=results, strings=strings, language="english", categories=settings["categories"]) def init(): global strings diff --git a/static/css/result.css b/static/css/result.css new file mode 100644 index 0000000..8cb4b41 --- /dev/null +++ b/static/css/result.css @@ -0,0 +1,4 @@ +table, th, td { + width: 100%; + border: 1px solid white; +} diff --git a/templates/result.html b/templates/result.html index dbccc72..4187527 100644 --- a/templates/result.html +++ b/templates/result.html @@ -5,5 +5,23 @@ vim: ts=2 noexpandtab {% block title %}{{ super() }} - Results{% endblock%} {% set active_page = "search" %} {% block content %} -
{{results}}
+ +Name | +Size | +Snatches | +UL | +DL | +
---|---|---|---|---|
{{ result[1] }} | +test | +N/A | +N/A | +N/A | + {% endfor %} +