-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
33 lines (27 loc) · 792 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
from flask import Flask, render_template, request
from Text_Summarization_Information_Extraction import *
import os
app = Flask(__name__)
#Controller
@app.route("/", methods = ["GET", "POST"])
def index():
data = ""
if method == "POST":
if 'file' in request.files:
file = request.files['file']
file_type = os.path.split(file)[1]
text = ''
if file_type == 'pdf':
text = extract_text_pdf(file)
elif file_type == 'txt':
with open(file, 'r') as f:
text = f.read()
result = summarize_text(text)
data = result
else:
text = request.get('text')
result = summarize_text(text)
data = result
return render_template("index.html", data = data)
if __name__ == "__main__":
app.run(debug = True)