tfrere commited on
Commit
6d3b050
·
1 Parent(s): 8ad9fad
client/src/config/api.js CHANGED
@@ -1,21 +1,9 @@
1
- // Detect if we're running in a HF Space
2
- const isHfSpace =
3
- window.location.hostname.endsWith(".hf.space") ||
4
- window.location !== window.parent.location;
5
-
6
- // Get the base API URL based on the environment
7
- const API_BASE_URL = isHfSpace
8
- ? `${window.location.origin}` // En production (HF Space), on utilise l'URL racine
9
- : "http://localhost:3002"; // En développement
10
 
11
  export const API_URLS = {
12
- leaderboards: `${API_BASE_URL}/api/leaderboards`,
13
- health: `${API_BASE_URL}/api/health`,
14
- };
15
-
16
- // Export additional environment info
17
- export const ENV_INFO = {
18
- isHfSpace,
19
  };
20
 
21
  export default API_URLS;
 
1
+ // URL du dataset Hugging Face
2
+ const HF_DATASET_URL =
3
+ "https://huggingface.co/datasets/leaderboard-explorer/leaderboard_explorer/raw/main/final_leaderboards.json";
 
 
 
 
 
 
4
 
5
  export const API_URLS = {
6
+ leaderboards: HF_DATASET_URL,
 
 
 
 
 
 
7
  };
8
 
9
  export default API_URLS;
client/src/pages/LeaderboardPage/LeaderboardPage.jsx CHANGED
@@ -25,12 +25,15 @@ const LeaderboardPageContent = () => {
25
 
26
  useEffect(() => {
27
  fetch(API_URLS.leaderboards)
28
- .then((res) => res.json())
 
 
 
 
 
29
  .then((data) => {
30
- const leaderboardsArray = Array.isArray(data)
31
- ? data
32
- : Object.values(data).filter((item) => Array.isArray(item))[0];
33
- setLeaderboards(leaderboardsArray);
34
  setLoading(false);
35
  })
36
  .catch((error) => {
 
25
 
26
  useEffect(() => {
27
  fetch(API_URLS.leaderboards)
28
+ .then((res) => {
29
+ if (!res.ok) {
30
+ throw new Error(`Failed to fetch leaderboards: ${res.status}`);
31
+ }
32
+ return res.json();
33
+ })
34
  .then((data) => {
35
+ // Les données sont directement dans le format attendu depuis le dataset HF
36
+ setLeaderboards(data);
 
 
37
  setLoading(false);
38
  })
39
  .catch((error) => {