app = Flask(__name__)
# Sample data for demonstration purposes
documents = {
1: "This is the first document.",
2: "A simple example for search.",
3: "Creating a search engine with Python and Flask."
}
@app.route('/')
def index():
return render_template('index.html')
@app.route('/search', methods=['POST'])
def search():
query = request.form.get('query')
results = {}
for doc_id, content in documents.items():
if query.lower() in content.lower():
results[doc_id] = content
return render_template('results.html', query=query, results=results)
if __name__ == '__main__':
app.run(debug=True)
0 Comments