forked from kyle-tapang-illinois/CourseProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (24 loc) · 860 Bytes
/
app.py
File metadata and controls
34 lines (24 loc) · 860 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
from flask import Flask, render_template, request, redirect, url_for, render_template
from Ranker import ranker
import pandas as pd
app = Flask(__name__)
@app.route("/", methods=["GET","POST"])
def home():
error = None
if request.method == "POST":
searchData= request.form["searchData"]
if searchData !="":
return redirect(url_for("hackerNewsSearchResults", searchData=searchData))
else:
error = 'Please enter your search data'
return render_template("home.html", error = error)
else:
return render_template("home.html")
@app.route("/hackerNewsSearchResults/<string:searchData>" , methods=["GET"])
def hackerNewsSearchResults(searchData):
df = ranker(searchData)
titles = df["title"].values
urls = df["link"].values
return render_template("searchResults.html", titles=titles, urls=urls)
if __name__ == "__main__":
app.run()