Geek7 commited on
Commit
357e80b
·
verified ·
1 Parent(s): 8b8721a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -17
app.py CHANGED
@@ -26,23 +26,22 @@ def main():
26
  # Use the hard-coded API key
27
  api_key = API_KEY
28
 
29
- # Continuously fetch and display real-time data
30
- while True:
31
- # Fetch Alpha Vantage data
32
- alpha_vantage_data = fetch_alpha_vantage_data(api_key, symbol)
33
-
34
- # Extract relevant data from Alpha Vantage response
35
- alpha_vantage_quote = alpha_vantage_data.get('Global Quote', {})
36
- df = pd.DataFrame([alpha_vantage_quote])
37
- df.index = [datetime.now()] # Use the current timestamp as the index
38
- df = df.dropna(axis=0)
39
-
40
- # Display the real-time data
41
- st.subheader("Real-Time Data:")
42
- st.write(df)
43
-
44
- # Add a delay to avoid exceeding API rate limits
45
- time.sleep(60) # Sleep for 60 seconds (adjust as needed)
46
 
47
  if __name__ == "__main__":
48
  main()
 
26
  # Use the hard-coded API key
27
  api_key = API_KEY
28
 
29
+ # Fetch Alpha Vantage data
30
+ alpha_vantage_data = fetch_alpha_vantage_data(api_key, symbol)
31
+
32
+ # Extract relevant data from Alpha Vantage response
33
+ alpha_vantage_quote = alpha_vantage_data.get('Global Quote', {})
34
+ df = pd.DataFrame([alpha_vantage_quote])
35
+ df.index = [datetime.now()] # Use the current timestamp as the index
36
+ df = df.dropna(axis=0)
37
+
38
+ # Display the real-time data
39
+ st.subheader("Real-Time Data:")
40
+ st.write(df)
41
+
42
+ # Notify user and stop the app
43
+ st.balloons()
44
+ st.stop()
 
45
 
46
  if __name__ == "__main__":
47
  main()