From d2057259c8b645f6c0e81fbc67e3219648b776f5 Mon Sep 17 00:00:00 2001 From: abrendan <94894839+abrendan@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:48:26 +0000 Subject: [PATCH] image search pages --- main.py | 4 +--- static/styles_results.css | 6 ++++++ templates/image_results.html | 10 ++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 67e0d4d..e3218c3 100644 --- a/main.py +++ b/main.py @@ -35,14 +35,13 @@ def search(): items = search_data.get('items', []) for item in items: - # Extract thumbnail if available, often found in `item['pagemap']['cse_thumbnail'][0]['src']` thumbnail = item.get('pagemap', {}).get('cse_thumbnail', [{}])[0].get('src', '/path-to-default-thumbnail.jpg') search_results.append({ 'title': item.get('title'), 'link': item.get('link'), 'snippet': item.get('snippet'), - 'thumbnail': thumbnail # Add this line to include the thumbnail URL + 'thumbnail': thumbnail }) total_results = int(search_data.get('searchInformation', {}).get('totalResults', 0)) @@ -94,6 +93,5 @@ def search_images(): return render_template('image_results.html', query=query, image_results=image_results, page=page, total_pages=total_pages) - if __name__ == '__main__': app.run(host='0.0.0.0', port=80) diff --git a/static/styles_results.css b/static/styles_results.css index 1b44350..2848b69 100644 --- a/static/styles_results.css +++ b/static/styles_results.css @@ -132,4 +132,10 @@ h1 { font-size: 0.9rem; } +.navigation-button { + margin-top: 1rem; + margin-right: 0.5rem; + width: auto; /* Allow the width to auto-adjust based on content */ + border-radius: 6px; +} diff --git a/templates/image_results.html b/templates/image_results.html index a16cb2c..4e63d76 100644 --- a/templates/image_results.html +++ b/templates/image_results.html @@ -24,6 +24,16 @@ {% endfor %} +