Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -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);
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("<p>the weather now is: " +wd+"<p>");
res.write("<img src="+imgicon +">");
res.write("<h1>dragt el 7rara y zeinab : "+temp+ "</h1>");
res.send();

})
})
});



app.listen(port ||3000,function(){
console.log("server is running")
});