Spaces:
Sleeping
Sleeping
Commit
·
fb4aa06
1
Parent(s):
f8d1456
Update app.py
Browse files
app.py
CHANGED
@@ -27,16 +27,18 @@ def fetch_and_display_data():
|
|
27 |
games_data = last_30_days_data(api_key)
|
28 |
if games_data:
|
29 |
df = pd.DataFrame(games_data)
|
30 |
-
|
|
|
|
|
31 |
else:
|
32 |
-
return "No data available."
|
33 |
else:
|
34 |
-
return "API Key not set."
|
35 |
|
36 |
interface = gr.Interface(
|
37 |
fn=fetch_and_display_data,
|
38 |
inputs=[],
|
39 |
-
outputs="dataframe",
|
40 |
title="NBA Games Data Fetcher",
|
41 |
description="Fetches the last 30 days of NBA games data. Make sure your API key is set in the environment variable 'NBA_API_KEY'."
|
42 |
)
|
|
|
27 |
games_data = last_30_days_data(api_key)
|
28 |
if games_data:
|
29 |
df = pd.DataFrame(games_data)
|
30 |
+
csv_file_path = '/tmp/nba_games_last_30_days.csv'
|
31 |
+
df.to_csv(csv_file_path, index=False)
|
32 |
+
return df, csv_file_path
|
33 |
else:
|
34 |
+
return "No data available.", None
|
35 |
else:
|
36 |
+
return "API Key not set.", None
|
37 |
|
38 |
interface = gr.Interface(
|
39 |
fn=fetch_and_display_data,
|
40 |
inputs=[],
|
41 |
+
outputs=["dataframe", "file"],
|
42 |
title="NBA Games Data Fetcher",
|
43 |
description="Fetches the last 30 days of NBA games data. Make sure your API key is set in the environment variable 'NBA_API_KEY'."
|
44 |
)
|