iukhan commited on
Commit
de3651f
·
verified ·
1 Parent(s): e374890

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -29
app.py CHANGED
@@ -1,29 +1,7 @@
1
- from flask import Flask, request, jsonify
2
- from io import BytesIO
3
- from PIL import Image
4
- import PyPDF2
5
- from docx import Document
6
- from wordcloud import WordCloud, STOPWORDS
7
-
8
- app = Flask(__name__)
9
-
10
- ALLOWED_EXTENSIONS = {'txt', 'pdf', 'docx'}
11
-
12
- def allowed_file(filename):
13
- return '.' in filename and \
14
- filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
15
-
16
- @app.route('/api/generate-wordcloud', methods=['POST'])
17
- def generate_wordcloud():
18
- if 'file' not in request.files:
19
- return jsonify({'error': 'Missing file upload'}), 400
20
-
21
- file = request.files['file']
22
- if file.filename == '':
23
- return jsonify({'error': 'No selected file'}), 400
24
-
25
- if file and allowed_file(file.filename):
26
- text = ''
27
- if file.filename.endswith('.txt'):
28
- text = file.read().decode('utf-8')
29
- elif file.filename.
 
1
+ import streamlit as st
2
+ from transformers import pipline
3
+ pipe =pipline('sentiment-analysis')
4
+ text=st.text_area('enter some text')
5
+ if text:
6
+ out=pip(text)
7
+ st.json(out)