Spaces:
Runtime error
Runtime error
File size: 670 Bytes
83ca6b0 6d0daba 83ca6b0 6d0daba 83ca6b0 |
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 |
# 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')
@app.route('/sentiment', methods=['POST'])
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() |