kubrabuzlu commited on
Commit
6987d13
·
verified ·
1 Parent(s): f980e28

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ from pydantic import BaseModel
4
+
5
+ # Define API endpoint
6
+ API_ENDPOINT = "http://localhost:8000/analyze/"
7
+
8
+ # Define data model for API request
9
+ class Text(BaseModel):
10
+ text: str
11
+
12
+ # Streamlit uygulamasını oluştur
13
+ st.title("Text Analysis App")
14
+
15
+ # Kullanıcıdan metin girişini al
16
+ input_text = st.text_area("Enter your text here:")
17
+
18
+ if st.button("Analyze"):
19
+ # Send request
20
+ response = requests.post(API_ENDPOINT, json=Text(text=input_text).dict())
21
+
22
+ # Check response
23
+ if response.status_code == 200:
24
+ result = response.json()
25
+ st.write("Sentiment:", result["sentiment"])
26
+ st.write("Intention:", result["intention"])
27
+ else:
28
+ st.error("An error occurred while analyzing the text.")