abolfazle80 commited on
Commit
852380d
Β·
verified Β·
1 Parent(s): bc1ed4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -20,7 +20,7 @@ markets = ['DOTUSDT', 'BTCUSDT', 'ADAUSDT', 'BNBUSDT', 'SUIUSDT', 'XRPUSDT']
20
  # Initialize Hugging Face API
21
  api = HfApi()
22
 
23
- # πŸ”Ή Initialize loop control variable
24
  loop_running = False
25
 
26
  # Function to fetch data from CoinEx
@@ -72,7 +72,7 @@ def upload_to_huggingface():
72
 
73
  # Function to fetch, append & update the CSV
74
  def fetch_data():
75
- global loop_running
76
  while loop_running:
77
  try:
78
  all_data = []
@@ -115,8 +115,7 @@ st.title("πŸ”„ Live Cryptocurrency Data Fetching")
115
 
116
  # Start Fetching Button
117
  if st.button("Start Fetching Data"):
118
- global loop_running
119
- if not loop_running:
120
  loop_running = True
121
  threading.Thread(target=fetch_data, daemon=True).start()
122
  st.success("βœ… Started fetching and saving data.")
 
20
  # Initialize Hugging Face API
21
  api = HfApi()
22
 
23
+ # πŸ”Ή Initialize loop control variable (Fixed Global Issue)
24
  loop_running = False
25
 
26
  # Function to fetch data from CoinEx
 
72
 
73
  # Function to fetch, append & update the CSV
74
  def fetch_data():
75
+ global loop_running # βœ… Fixed Scope Issue
76
  while loop_running:
77
  try:
78
  all_data = []
 
115
 
116
  # Start Fetching Button
117
  if st.button("Start Fetching Data"):
118
+ if not loop_running: # βœ… Fixed issue by ensuring variable scope
 
119
  loop_running = True
120
  threading.Thread(target=fetch_data, daemon=True).start()
121
  st.success("βœ… Started fetching and saving data.")