-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleapp_test.py
More file actions
27 lines (20 loc) · 724 Bytes
/
simpleapp_test.py
File metadata and controls
27 lines (20 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from flask import Flask, render_template, request
import pandas as pd
app = Flask(__name__)
# Load your dataset
df = pd.read_csv('dataset.csv')
def generate_boolean_query(terms):
return " AND ".join([f"{term.strip()}" for term in terms])
def search_articles(query):
return df[df['abstract'].str.contains(query, case=False, na=False)]
@app.route('/')
def home():
return render_template('index.html')
@app.route('/search', methods=['POST'])
def search():
terms = request.form['terms'].split(',')
boolean_query = generate_boolean_query(terms)
results = search_articles(boolean_query)
return render_template('results.html', results=results)
if __name__ == '__main__':
app.run(debug=True)