Published on 25-08-2025
This project creates a content-based book recommendation engine that suggests similar books to readers based on their input. The focus was on Flask for the web interface and Python for backend logic.
popular.pkl, pt.pkl, books.pkl, and similarity_scores.pkl/ → shows popular books/recommend → search UI for user input
Homepage & Search Page
Recommendation Results Page
@app.route('/recommend_books', methods=['POST'])
def recommend():
user_input = request.form.get('user_input').strip().lower()
index_array = np.where(pt.index.str.lower() == user_input)[0]
if len(index_array) == 0:
return render_template('recommend.html', data=[], error="⚠️ Book not found!")
index = index_array[0]
similar_items = sorted(list(enumerate(similarity_scores[index])),
key=lambda x: x[1], reverse=True)[1:5]
data = []
for i in similar_items:
temp_df = books[books['Book-Title'].str.lower() == pt.index[i[0]].lower()]
if not temp_df.empty:
data.append([temp_df['Book-Title'].values[0],
temp_df['Book-Author'].values[0],
temp_df['Image-URL-M'].values[0]])
return render_template('recommend.html', data=data)
This route processes user input and displays the recommended books.
This Book Recommender is a lightweight Flask application that shows how similarity-based approaches can deliver personalized book suggestions. Future improvements could include collaborative filtering and hybrid recommendations using user ratings.