-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Search🔍] Implemented a simple search algo for recipes
- Loading branch information
[esekyi]
committed
Sep 7, 2024
1 parent
5b30286
commit 11df8e4
Showing
4 changed files
with
81 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
from flask import Blueprint, request, render_template | ||
from app.services.search_service import search_recipes | ||
|
||
search_bp = Blueprint('search', __name__) | ||
search_bp = Blueprint('search', __name__) | ||
|
||
|
||
@search_bp.route('/search', methods=['GET'], strict_slashes=False) | ||
def search(): | ||
query = request.args.get('q', '').strip() | ||
page = int(request.args.get('page', 1)) | ||
per_page = int(request.args.get('per_page', 10)) | ||
|
||
if not query: | ||
return render_template('search_results.html', query=query, recipes=[]) | ||
|
||
results = search_recipes(query, page, per_page) | ||
|
||
return render_template( | ||
'search_results.html', | ||
query=query, | ||
recipes=results['items'], | ||
total_pages=results['total_pages'], | ||
current_page=results['current_page'], | ||
per_page=results['per_page'], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.