atharvapawar's picture
flask app
83ca6b0
raw
history blame
670 Bytes
# 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()