Spaces:
Runtime error
Runtime error
Added secrets
Browse files
app.py
CHANGED
@@ -12,9 +12,13 @@ new_transactions = [i.strip() for i in new_transactions if i.strip()]
|
|
12 |
# Submit button for new transactions
|
13 |
if st.button("Submit New Transactions"):
|
14 |
url = "https://api.runpod.ai/v2/0wnm75vx5o77s1/run"
|
|
|
|
|
|
|
|
|
15 |
headers = {
|
16 |
'Content-Type': 'application/json',
|
17 |
-
'Authorization':
|
18 |
}
|
19 |
data = {
|
20 |
'input': {
|
@@ -41,9 +45,7 @@ if st.button("Submit New Transactions"):
|
|
41 |
status_response = requests.get(status_url, headers=headers)
|
42 |
status_data = status_response.json()
|
43 |
status = status_data.get('status', '')
|
44 |
-
time.sleep(
|
45 |
-
|
46 |
-
st.write(f"Current status: {status}")
|
47 |
|
48 |
# Once status changes, display final status
|
49 |
st.write("Final status:", status_data)
|
@@ -51,27 +53,6 @@ if st.button("Submit New Transactions"):
|
|
51 |
except requests.exceptions.RequestException as e:
|
52 |
st.error(f"An error occurred: {e}")
|
53 |
|
54 |
-
# Input and button for fetching status or result by job ID
|
55 |
-
st.subheader("Fetch Status or Result by Job ID")
|
56 |
-
job_id_input = st.text_input("Enter Job ID")
|
57 |
-
|
58 |
-
if st.button("Fetch Status or Result"):
|
59 |
-
if job_id_input:
|
60 |
-
try:
|
61 |
-
status_url = f"https://api.runpod.ai/v2/0wnm75vx5o77s1/status/{job_id_input}"
|
62 |
-
headers = {
|
63 |
-
'Authorization': 'API_KEY'
|
64 |
-
}
|
65 |
-
|
66 |
-
# Fetch status or result based on job ID
|
67 |
-
status_response = requests.get(status_url, headers=headers)
|
68 |
-
status_data = status_response.json()
|
69 |
-
|
70 |
-
# Display status or result
|
71 |
-
st.write("Status or Result:", status_data)
|
72 |
-
|
73 |
-
except requests.exceptions.RequestException as e:
|
74 |
-
st.error(f"An error occurred: {e}")
|
75 |
|
76 |
else:
|
77 |
if st.button("Reset"):
|
|
|
12 |
# Submit button for new transactions
|
13 |
if st.button("Submit New Transactions"):
|
14 |
url = "https://api.runpod.ai/v2/0wnm75vx5o77s1/run"
|
15 |
+
|
16 |
+
# Retrieve API key from Streamlit secrets
|
17 |
+
api_key = st.secrets["api_key"]
|
18 |
+
|
19 |
headers = {
|
20 |
'Content-Type': 'application/json',
|
21 |
+
'Authorization': api_key
|
22 |
}
|
23 |
data = {
|
24 |
'input': {
|
|
|
45 |
status_response = requests.get(status_url, headers=headers)
|
46 |
status_data = status_response.json()
|
47 |
status = status_data.get('status', '')
|
48 |
+
time.sleep(2) # Adjust interval as needed
|
|
|
|
|
49 |
|
50 |
# Once status changes, display final status
|
51 |
st.write("Final status:", status_data)
|
|
|
53 |
except requests.exceptions.RequestException as e:
|
54 |
st.error(f"An error occurred: {e}")
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
else:
|
58 |
if st.button("Reset"):
|