-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
46 lines (33 loc) · 1.17 KB
/
app.py
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
40
41
42
43
44
45
46
from flask import Flask, request, jsonify, redirect
from systems import Ranker, Recommender
from systems import Ranker
app = Flask(__name__)
ranker = Ranker()
recommender = Recommender()
@app.route('/')
def redirect_to_test():
return redirect("/test", code=302)
@app.route('/test', methods=["GET"])
def test():
return 'Container is running', 200
@app.route('/index', methods=["GET"])
def index():
# ranker.index()
recommender.index()
return 'Indexing done!', 200
@app.route('/ranking', methods=["GET"])
def ranking():
query = request.args.get('query', None)
page = request.args.get('page', default=0, type=int)
rpp = request.args.get('rpp', default=20, type=int)
response = ranker.rank_publications(query, page, rpp)
return jsonify(response)
@app.route('/recommendation/datasets', methods=["GET"])
def rec_data():
item_id = request.args.get('item_id', None)
page = request.args.get('page', default=0, type=int)
rpp = request.args.get('rpp', default=20, type=int)
response = recommender.recommend_datasets(item_id, page, rpp)
return jsonify(response)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)