from flask import Flask, render_template, request from search_engine_functions import search # Define the search function (You will need to implement this) # Initialize the Flask application app = Flask(__name__) index_dir = "src/search_engine/index" # Define a route (URL) for the homepage @app.route('/') def home(): return render_template('index.html') # Render an HTML template for the home page # Define a route to handle search requests @app.route('/search', methods=['POST']) def search_request(): query = request.form['query'] # Get the search term from the submitted form results = search(query,index_dir) # Perform the search using your search function return render_template('results.html', query=query, results=results) # Render the search results # Start the Flask development server if the script is run directly if __name__ == '__main__': app.run(host='0.0.0.0', port=7860)