-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
73 lines (66 loc) · 2.19 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from flask import Flask, request, jsonify
from flask_cors import CORS, cross_origin
import json
import requests
from summarizer import summarizer_util
import os
from os.path import join, dirname
# from dotenv import load_dotenv
# dotenv_path = join(dirname(__file__), '.env')
# load_dotenv(dotenv_path)
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
@app.route('/text/<user_id>', methods=['POST'])
@cross_origin()
def text(user_id):
meet_data = request.get_json()
meet_transcript = meet_data['transcript']
subject_name = meet_data['subject_name']
lecture_name = meet_data['lecture_name']
email = meet_data['email']
images = meet_data['images']
is_gmeet = meet_data['is_gmeet']
num_lines = int(meet_data['num_lines'])
if images == None:
images = []
print(meet_transcript, subject_name, images, num_lines, type(num_lines))
meet_text = ""
if not is_gmeet:
for data in meet_transcript:
meet_text += data['text']
meet_text += ". "
else:
meet_text = meet_transcript
# print("==============")
meet_summary = summarizer_util_sk(meet_text, num_lines)
# print("==============")
#print(summarizer_util_p(meet_text, num_lines))
# print("==============")
#print(summarizer_util_sp(meet_text, num_lines))
# print("==============")
# print(meet_text)
#meet_text_p = summarizer_util_p(meet_text, num_lines)
#meet_text_s = summarizer_util(meet_text, num_lines)
#meet_text_k = summarizer_util(meet_text, num_lines)
# print(meet_text_p)
# print("==============")
# print(meet_text_s)
# print("==============")
# print(meet_text_k)
# print("================")
data = {
"email": email,
"folder": subject_name,
"title": lecture_name,
"content": meet_summary,
"snapshots": images
}
print(data)
headers = {'Content-type': 'application/json'}
res = requests.post(
url='https://gisty-server.herokuapp.com/api/summaries/create', data=json.dumps(data), headers=headers)
print(res.text)
return jsonify({'msg': 'sucessfully added'}), 200
if __name__ == '__main__':
app.run(debug=True)