From 65f199d6ddd5b02c6e72da411edda270736dcbb3 Mon Sep 17 00:00:00 2001
From: mohamedhaffiz <151659121+mohamedhaffiz@users.noreply.github.com>
Date: Fri, 5 Jan 2024 08:54:15 +0200
Subject: [PATCH] Update index.js

---
 index.js | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

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("<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")
+    });