poemsforaphrodite commited on
Commit
2b93622
·
verified ·
1 Parent(s): f37bc4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -6
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import requests
3
  from io import BytesIO
 
4
 
5
  # Set the page configuration
6
  st.set_page_config(
@@ -45,13 +46,28 @@ if submit_button:
45
  # **Corrected API endpoint**
46
  api_url = "https://tellergen.com/api/clone-voice"
47
 
48
- # **Optional: Add headers if your API requires authentication**
49
- # headers = {
50
- # 'Authorization': 'Bearer YOUR_API_TOKEN'
51
- # }
52
-
53
  with st.spinner("Sending request to the API..."):
54
- response = requests.post(api_url, data=payload, files=files) # , headers=headers
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  # Check if the request was successful
57
  if response.status_code == 200:
 
1
  import streamlit as st
2
  import requests
3
  from io import BytesIO
4
+ from requests.exceptions import ConnectionError, SSLError, Timeout
5
 
6
  # Set the page configuration
7
  st.set_page_config(
 
46
  # **Corrected API endpoint**
47
  api_url = "https://tellergen.com/api/clone-voice"
48
 
 
 
 
 
 
49
  with st.spinner("Sending request to the API..."):
50
+ try:
51
+ response = requests.post(
52
+ api_url,
53
+ data=payload,
54
+ files=files,
55
+ verify=False, # Disable SSL verification
56
+ timeout=30 # Set timeout to 30 seconds
57
+ )
58
+ response.raise_for_status()
59
+ except ConnectionError as e:
60
+ st.error("Connection error. Please check your internet connection and try again.")
61
+ return
62
+ except SSLError as e:
63
+ st.error("SSL Error occurred. Please try again later.")
64
+ return
65
+ except Timeout as e:
66
+ st.error("Request timed out. Please try again later.")
67
+ return
68
+ except Exception as e:
69
+ st.error(f"An unexpected error occurred: {str(e)}")
70
+ return
71
 
72
  # Check if the request was successful
73
  if response.status_code == 200: