-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>De Lijn Realtime Data</title> | ||
<script> | ||
async function fetchRealtimeData() { | ||
try { | ||
const response = await fetch("https://api.delijn.be/gtfs/v3/realtime", { | ||
method: "GET", | ||
headers: { | ||
"Cache-Control": "no-cache", | ||
"Ocp-Apim-Subscription-Key": "24668cab5bac4d27bfafe5013a8fab3b" | ||
} | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`Error: ${response.status}`); | ||
} | ||
|
||
const data = await response.json(); | ||
saveJsonToFile(data); | ||
} catch (error) { | ||
console.error('Failed to fetch data', error); | ||
} | ||
} | ||
|
||
function saveJsonToFile(data) { | ||
const json = JSON.stringify(data, null, 2); | ||
const blob = new Blob([json], { type: "application/json" }); | ||
const url = URL.createObjectURL(blob); | ||
|
||
const a = document.createElement('a'); | ||
a.href = url; | ||
a.download = 'realtime_data.json'; | ||
a.click(); | ||
|
||
URL.revokeObjectURL(url); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<h1>De Lijn Realtime Data</h1> | ||
<button onclick="fetchRealtimeData()">Download JSON</button> | ||
</body> | ||
</html> |