diff --git a/app.py b/app.py index 24007fb..6dc77b7 100644 --- a/app.py +++ b/app.py @@ -232,5 +232,31 @@ def item_image(tpl): details = get_item_details_cached(tpl) return jsonify({'image512pxLink': details.get('image512pxLink', ''), 'name': details.get('name', '')}) +@app.route('/search_items', methods=['GET']) +def search_items(): + query = request.args.get('query', '') + if not query: + return jsonify([]) + + search_query = f''' + {{ + items(name: "{query}") {{ + id + name + gridImageLink + }} + }} + ''' + + try: + response = requests.post(TARKOV_API_URL, json={'query': search_query}) + data = response.json() + items = data['data'].get('items', []) + return jsonify(items) + except Exception as e: + logging.error(f"Error searching for items with query '{query}': {e}") + logging.error(traceback.format_exc()) + return jsonify([]), 500 + if __name__ == '__main__': app.run(debug=True) diff --git a/templates/edit.html b/templates/edit.html index 6dbbf1f..5318a51 100644 --- a/templates/edit.html +++ b/templates/edit.html @@ -55,6 +55,18 @@ width: 30px; margin-right: 5px; } + .search-result-item { + display: flex; + align-items: center; + margin-bottom: 10px; + } + .search-result-item img { + width: 30px; + margin-right: 10px; + } + .search-result-item button { + margin-left: auto; + }
@@ -130,6 +142,13 @@ {% endif %} {% endif %} + + +