Spaces:
Runtime error
Runtime error
from flask import Flask, render_template, request, jsonify | |
from transformers import pipeline | |
app = Flask(__name__) | |
# Load the Hugging Face summarization model | |
summarizer = pipeline("summarization", model="Ramji/bart-cn-large-medical-summary") | |
# Route to display the home page | |
def home(): | |
return render_template('index.html') | |
# Route to handle the summarization request | |
def summarize(): | |
data = request.get_json() # Get the data from the client-side request | |
text = data.get("text") | |
if text: | |
# Perform summarization | |
summary = summarizer(text) | |
print(summary) | |
return jsonify({"summary": summary[0]['summary_text']}) | |
else: | |
return jsonify({"error": "No text provided"}), 400 | |
if __name__ == '__main__': | |
app.run(debug=True) | |