-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (19 loc) · 678 Bytes
/
Copy pathapp.py
File metadata and controls
34 lines (19 loc) · 678 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
28
29
30
31
32
33
34
from preprocessing import load_articles
from preprocessing import query_processing
from flask import Flask, render_template, Response, request
import json
import warnings
warnings.filterwarnings("ignore", category=UserWarning)
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/result', methods=['POST'])
def search():
query = request.form['query']
sims = query_processing(query)
articles = load_articles()
top_articles = [articles[sim[0]] for sim in sims[:10]]
return render_template('result.html', articles=top_articles)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)