Skip to content

Commit d7b321a

Browse files
committed
API fetch changes
1 parent 25c405f commit d7b321a

File tree

1 file changed

+3
-10
lines changed
  • workshops/serverless-testing-workshop/demo-app

1 file changed

+3
-10
lines changed

workshops/serverless-testing-workshop/demo-app/urs-ui.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
if output['OutputKey'] == 'ApiEndpoint':
2626
st.session_state['api_endpoint_url'] = output['OutputValue']
2727
except:
28-
print("Failed to get API Endpoint from CloudFormation Stack")
29-
30-
if os.path.isfile("config.json") and 'api_endpoint_url' not in st.session_state:
31-
with open("config.json","r",encoding="utf-8") as f:
32-
app_config = json.load(f)
33-
st.session_state['api_endpoint_url'] = app_config["api_endpoint"].strip()
34-
else:
3528
st.session_state['api_endpoint_url'] = "https://{APIGATEWAYID}.execute-api.{REGION}.amazonaws.com/Prod/"
3629

3730
if 'unicorn_art' not in st.session_state:
@@ -225,14 +218,14 @@ def update_unicorn_reserve_list():
225218
key="api_endpoint_url",
226219
on_change=update_api_endpoint
227220
)
228-
if st.button("Retrieve API Endpoint"):
221+
if st.button(f"Reset API Endpoint from Stack"):
229222
cfn_client = boto3.client('cloudformation')
230223
response = cfn_client.describe_stacks(StackName=os.environ.get('BACKEND_STACK_NAME','urs-backend'))
231224
for output in response['Stacks'][0]['Outputs']:
232225
if output['OutputKey'] == 'ApiEndpoint':
233-
st.session_state['api_endpoint_url'] = output['OutputValue']
226+
st.write(f"Resetting API Endpoint to: {output['OutputValue']}")
227+
234228

235-
236229
# File picker for uploading to the unicorn inventory
237230
uploaded_file = st.file_uploader("Choose a CSV file for the Unicorn Inventory.", type=["csv"])
238231
if uploaded_file is not None:

0 commit comments

Comments
 (0)