-
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
Glitch (osde8info-opensky)
committed
Jan 9, 2020
1 parent
34f77f7
commit 166feac
Showing
8 changed files
with
963 additions
and
674 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,6 @@ | ||
{"name":"drag-in-files.svg","date":"2016-10-22T16:17:49.954Z","url":"https://cdn.hyperdev.com/drag-in-files.svg","type":"image/svg","size":7646,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/drag-in-files.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(102, 153, 205)","uuid":"adSBq97hhhpFNUna"} | ||
{"name":"click-me.svg","date":"2016-10-23T16:17:49.954Z","url":"https://cdn.hyperdev.com/click-me.svg","type":"image/svg","size":7116,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/click-me.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(243, 185, 186)","uuid":"adSBq97hhhpFNUnb"} | ||
{"name":"paste-me.svg","date":"2016-10-24T16:17:49.954Z","url":"https://cdn.hyperdev.com/paste-me.svg","type":"image/svg","size":7242,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/paste-me.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(42, 179, 185)","uuid":"adSBq97hhhpFNUnc"} | ||
{"uuid":"adSBq97hhhpFNUna","deleted":true} | ||
{"name":"Lato-Regular.woff2","date":"2019-05-01T07:41:37.691Z","url":"https://cdn.glitch.com/f96de787-913b-49de-8418-3a9f8f50f829%2FLato-Regular.woff2","type":"","size":182708,"thumbnail":"https://cdn.glitch.com/f96de787-913b-49de-8418-3a9f8f50f829%2Fthumbnails%2FLato-Regular.woff2","thumbnailWidth":210,"thumbnailHeight":210,"uuid":"uObL2RX15JXQNKjS"} | ||
{"uuid":"uObL2RX15JXQNKjS","deleted":true} |
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,4 @@ | ||
Shows the arrivals and departures for your chosen AIRPORT from opensky-network.org | ||
|
||
Remixed from https://airqualitysg.glitch.me/ | ||
|
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,27 @@ | ||
{ | ||
"name": "osde8info-opensky", | ||
"version": "0.0.1", | ||
"description": "osde8info-opensky", | ||
"main": "server.js", | ||
"scripts": { | ||
"start": "node server.js" | ||
}, | ||
"dependencies": { | ||
"express": "^4.17.1", | ||
"pug": "^2.0.4", | ||
"axios": "^0.19.1" | ||
}, | ||
"engines": { | ||
"node": "10.x" | ||
}, | ||
"repository": { | ||
"url": "https://glitch.com/edit/#!/osde8info-opensky" | ||
}, | ||
"license": "GNU V3", | ||
"keywords": [ | ||
"node", | ||
"glitch", | ||
"express", | ||
"opensky-network" | ||
] | ||
} |
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,73 @@ | ||
const express = require("express"); | ||
const axios = require("axios"); | ||
|
||
const airport = process.env.AIRPORT; // EGLL | ||
|
||
const app = express(); | ||
|
||
app.locals.pretty = true; | ||
|
||
app.set("view engine", "pug") | ||
|
||
app.get("/", async (_, res) => { | ||
const flights = await getFlights() | ||
res.render("index", flights) | ||
}); | ||
|
||
async function getFlights() { | ||
let flights = { | ||
date: "", | ||
arrivals: "", | ||
departures: "" | ||
}; | ||
|
||
var start = new Date(); | ||
flights.date = start; | ||
var start = Math.floor(start / 1000) - 200000; | ||
var end = start + 300; | ||
|
||
try { | ||
const url = "https://opensky-network.org/api/flights/"; | ||
|
||
var params = { airport: airport, begin: start, end: end }; | ||
var response = await axios.get(url + "arrival", { params }); | ||
console.log(response.status); | ||
|
||
var data = response.data; | ||
var s = ""; | ||
|
||
for (let i = 0; i < data.length; i++) { | ||
s = s + data[i].callsign + " "; | ||
s = s + data[i].estDepartureAirport + " "; | ||
s = s + data[i].estArrivalAirport + " "; | ||
s = s + data[i].estArrivalAirportHorizDistance + " "; | ||
s = s + data[i].estArrivalAirportVertDistance + " "; | ||
s = s + "\n"; | ||
} | ||
|
||
flights.arrivals = s; | ||
|
||
params = { airport: airport, begin: start, end: end }; | ||
var response = await axios.get(url + "departure", { params }); | ||
console.log(response.status); | ||
|
||
var data = response.data; | ||
var s = ""; | ||
|
||
for (let i = 0; i < data.length; i++) { | ||
s = s + data[i].callsign + " "; | ||
s = s + data[i].estDepartureAirport + " "; | ||
s = s + data[i].estArrivalAirport + " "; | ||
s = s + data[i].estArrivalAirportHorizDistance + " "; | ||
s = s + data[i].estArrivalAirportVertDistance + "\n"; | ||
} | ||
|
||
flights.departures = s; | ||
|
||
return flights; | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
|
||
app.listen(process.env.PORT); |
Oops, something went wrong.