-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
34 lines (23 loc) · 832 Bytes
/
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
from flask import Flask, request, jsonify, redirect
from systems import Recommender
app = Flask(__name__)
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():
recommender.index()
return "Indexing done!", 200
@app.route("/recommendation/publications", methods=["GET"])
def rec_pub():
item_id = request.args.get("item_id", None)
page = request.args.get("page", default=0, type=int)
rpp = request.args.get("rpp", default=60, type=int)
response = recommender.recommend_publications(item_id, page, rpp)
return jsonify(response)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)