-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__init__.py
More file actions
39 lines (30 loc) · 1.06 KB
/
__init__.py
File metadata and controls
39 lines (30 loc) · 1.06 KB
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
35
36
37
38
39
from flask import Flask, render_template, request, jsonify
from collegeinfo import Colleges
from analyzer import Analyzer
app = Flask(__name__)
c = Colleges()
a = Analyzer()
@app.route('/')
def index():
return render_template('index.html')
@app.route('/searchSchool', methods=['POST'])
def search():
school = request.form["school"].encode('utf-8')
coords = c.get_coords_from_name(school)
yakList = a.get_yaks_by_coords(coords[0],coords[1])
#ave = a.get_weighted_average_sentiments(yakList)
#keywords = a.get_keywords_for_yaks(yakList)
yaks = []
for i in range(len(yakList)):
yaks.append({"yak":yakList[i].message, "votes":yakList[i].likes})
gps = [{"lat":coords[0], "long":coords[1]}]
return jsonify({"yaks":yaks, 'coords':gps})
@app.route('/getWeightedAverages', methods=['POST'])
def weighted():
return jsonify(a.get_weighted_average_sentiments())
@app.route('/getKeywords', methods=['POST'])
def keywords():
# return jsonify({"keywords":a.get_keywords_for_yaks()})
return str(a.get_keywords_for_yaks())
if __name__ == "__main__":
app.run(debug=True)