File size: 948 Bytes
eb147f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from flask import Flask, render_template, request, jsonify
from tf_model_api.model_api import ModelAPI

app = Flask(__name__)
# Create the model class object
summarizer_model = ModelAPI()

@app.route('/')
def index():
    data = {
        'prompts': ''
    }
    return render_template('index.html', data=data)

@app.route('/create-summary', methods=['POST'])
def creat_summary_response():
    """
    create a summary using the input received 
    from the user.
    """

    data = request.get_json()  # Extract the JSON data from the request
    text = data.get('text')    # Get the 'text' field from the JSON data

    summary = summarizer_model.get_summary(text)
    if summary:
        result = {
            'status': 'success',
            'result': summary}
        return jsonify(result), 200
    else:
        result = {
            'status': 'fail'
        }
        return jsonify(result), 400

if __name__ == '__main__':
    app.run()