Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
- [Dhroov Makwana](https://github.com/pabloescoder)
- [Prince Roy](https://www.github.com/iprinceroyy)
- [Prannov Jamadagni](https://github.com/Prannov)
-
- [Shriyansh Gaur](https://github.com/SHRIYANSHGAUR)

-[Your name](your-github_url or linkedlin-url) : *Don't edit this template*

Expand Down
73 changes: 73 additions & 0 deletions Web Dev Projects_or_Portfolios/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const express = require("express");
const bodyPARSER= require("body-parser");
const app= express();
const https= require("https");
/// https is used to get data from a external sserver



app.use(bodyPARSER.urlencoded({extended:true}));


app.get("/", function(req,res){

res.sendFile(__dirname + "/index.html");

});


app.post("/", function(req,res){

const cname= req.body.cityname;
const country= req.body.countryname;


const url="https://api.openweathermap.org/data/2.5/weather?q="+ cname+","+ country +"&units=metric&appid=435a6d9426567380086e2c86a104fb87";
https.get(url, function(response){


////to display

response.on("data", function(data){

const weatherDATA= JSON.parse(data);

/// to acess individual elements
//weatherDATA.main.temp; like objects

//console.log(weatherDATA);
//
const temp= weatherDATA.main.temp;
const lat= weatherDATA.coord.lat;

const lon= weatherDATA.coord.lon;

const des= weatherDATA.weather[0].description;

const pic= weatherDATA.weather[0].icon;



res.write("<h1>TEMPerature in"+ cname+","+ country +" is "+ temp+"degree Celcius</h1>");
res.write("<p>latttitude"+lat+ "longitude"+lon+ "</p>");
res.write("<h1>WEATHER HERE IS ...>>"+des+"</h1>");

const imgURL= "http://openweathermap.org/img/wn/"+ pic +"@2x.png" ;
res.write("<img src=" +imgURL +">");
res.send();
// weather[0] as its an array with only one element.....

});
});
});

////NOTE.... we can have only one res.send() in a app.get()////
/// to send more than one data we need to create more app.get
//orrrrrrrrr we use res.write() many times to print what we need and at end res.send() only once////




///// lisening line created in starting placed at end

app.listen(3000, function(){console.log("SERVER RUNNING AT PORT 3000") });
19 changes: 19 additions & 0 deletions Web Dev Projects_or_Portfolios/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title> LIVE WEATHER</title>
</head>
<body>
<form action="/" method="post" >
<label for="city"> CITY NAME :</label>
<input id = "city" type="text" name="cityname" >
<label for="country"> COUNTRY NAME :</label>

<input id = "country" type="text" name="countryname" >

<button type="submit" name=""> GO </button>

</form>
</body>
</html>
Loading