diff --git a/index.js b/index.js index 5f35242ee8..46e04b326e 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,34 @@ -var http = require('http'); -http.createServer(function (req, res) { - console.log(`Just got a request at ${req.url}!`) - res.write('Yo!'); - res.end(); -}).listen(process.env.PORT || 3000); \ No newline at end of file +const express = require('express'); +const https = require('https'); + +const app = express(); + +const port = process.env.PORT; + +const path = "https://api.openweathermap.org/data/2.5/weather?q=ismailia&units=metric&appid=55ae2cfdf62317ff0660600606148f95"; + +app.get("/",function(req,res){ + + https.get(path, function(response){ + + response.on("data",function(data){ + const weatherData = JSON.parse(data); + const temp = weatherData.main.temp + const wd = weatherData.weather[0].description + const icon = weatherData.weather[0].icon + const imgicon = "https://openweathermap.org/img/wn/"+icon+"@2x.png" + + res.write("
the weather now is: " +wd+"
"); + res.write(""); + res.write("