-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
31 lines (25 loc) · 834 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
from flask import Flask, json, render_template, request, jsonify
from text_summ2 import summarise
app = Flask(__name__)
@app.route("/")
def home():
return render_template("index.html")
@app.route("/", methods = ['POST', 'GET'])
def summary():
url = request.form.get("url")
try:
summary = summarise(url)
except:
return render_template("index.html", summary = "Sorry, summary could not be created!")
return render_template("index.html", summary = summary)
@app.route("/summarise", methods = ['POST'])
def get_summary():
data = request.get_json()
#validate url
try:
summary = summarise(data['url'])
except:
return jsonify({'message' : 'Summary could not be created!'})
return jsonify({'summary' : summary})
if __name__ == "__main__":
app.run(debug=True)