Spaces:
Running
Running
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() | |
def index(): | |
data = { | |
'prompts': '' | |
} | |
return render_template('index.html', data=data) | |
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() |