Jhenderson112 commited on
Commit
eb147f2
·
1 Parent(s): cb4687b

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +38 -0
main.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request, jsonify
2
+ from tf_model_api.model_api import ModelAPI
3
+
4
+ app = Flask(__name__)
5
+ # Create the model class object
6
+ summarizer_model = ModelAPI()
7
+
8
+ @app.route('/')
9
+ def index():
10
+ data = {
11
+ 'prompts': ''
12
+ }
13
+ return render_template('index.html', data=data)
14
+
15
+ @app.route('/create-summary', methods=['POST'])
16
+ def creat_summary_response():
17
+ """
18
+ create a summary using the input received
19
+ from the user.
20
+ """
21
+
22
+ data = request.get_json() # Extract the JSON data from the request
23
+ text = data.get('text') # Get the 'text' field from the JSON data
24
+
25
+ summary = summarizer_model.get_summary(text)
26
+ if summary:
27
+ result = {
28
+ 'status': 'success',
29
+ 'result': summary}
30
+ return jsonify(result), 200
31
+ else:
32
+ result = {
33
+ 'status': 'fail'
34
+ }
35
+ return jsonify(result), 400
36
+
37
+ if __name__ == '__main__':
38
+ app.run()