Spaces:
Runtime error
Runtime error
# import streamlit as st | |
# from transformers import pipeline | |
# pipe = pipeline('sentiment-analysis') | |
# text = st.text_area('enter some text!') | |
# if text: | |
# out = pipe(text) | |
# st.write(out) | |
# My Flask App | |
import json | |
from flask import Flask, request, jsonify | |
from transformers import pipeline | |
app = Flask(__name__) | |
pipe = pipeline('sentiment-analysis') | |
def sentiment_analysis(): | |
data = request.get_json() | |
text = data['text'] | |
if text: | |
out = pipe(text) | |
return jsonify(out) | |
else: | |
return jsonify({"error": "No text provided."}), 400 | |
if __name__ == '__main__': | |
app.run() |