diff --git a/app.py b/app.py
index 6a1f372..59d7032 100644
--- a/app.py
+++ b/app.py
@@ -1,75 +1,47 @@
-from flask import Flask, render_template, request, send_from_directory
+from flask import Flask, request, send_from_directory
import os
+
+# Initialize Flask app
app = Flask(__name__)
-EPUBS_DIR = {
- 'default': './bookshelf/'
-}
-
+# Directory containing EPUB files
+EPUBS_DIR = './bookshelf/'
@app.route('/')
def index():
- return send_from_directory(app.root_path,'index.html')
-
+ # Serve the main HTML page
+ return send_from_directory(app.root_path, 'index.html')
@app.route('/search', methods=['GET'])
def search():
+ # Get the search query parameter and convert it to lowercase for case-insensitive matching
query = request.args.get('searchQuery', '').lower()
+
+ # List to store filenames of matching EPUB files
matching_files = []
- for _, dir_path in EPUBS_DIR.items():
- all_files = [f for f in os.listdir(dir_path) if f.lower().endswith('.epub')]
- matching_files += [f for f in all_files if query in f.lower()]
+
+ # Fetch all EPUB files from the directory and filter them based on the search query
+ all_files = [f for f in os.listdir(EPUBS_DIR) if f.lower().endswith('.epub')]
+ matching_files += [f for f in all_files if query in f.lower()]
- # Render the results as HTML
+ # Generate HTML for the list of matching files
results_html = "".join([f'