-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.py
48 lines (34 loc) · 1.11 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
47
48
from flask import Flask, request
from flask_restful import reqparse, Resource, Api
from flask_cors import CORS, cross_origin
from utils import text_cleaner, links_generator, quiz
from summa import summarizer
app = Flask(__name__)
CORS(app)
api = Api(app)
parser = reqparse.RequestParser()
class Summary(Resource):
def get(self):
return {'hello': 'world'}
def post(self):
parser.add_argument('data')
args = parser.parse_args()
html = args["data"]
raw_data = text_cleaner.get_article_from_html(html).text
smry = summarizer.summarize(raw_data, words=250)
related_links = links_generator.get_links_for_article(raw_data)
return {'summary': smry, 'related_links': related_links}
class Quiz(Resource):
def get(self):
return {'hello': 'world'}
def post(self):
parser.add_argument('data')
args = parser.parse_args()
html = args["data"]
raw_data = text_cleaner.get_article_from_html(html).text
qz = quiz.generate_quiz(raw_data)
return {'data': qz}
api.add_resource(Summary, '/summary')
api.add_resource(Quiz, '/quiz')
if __name__ == '__main__':
app.run(debug=True)