Text / main.py
Jhenderson112's picture
Upload main.py
eb147f2
raw
history blame contribute delete
948 Bytes
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()