-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from Omm-Pani/main
issue no.#46 resolved
- Loading branch information
Showing
429 changed files
with
62,252 additions
and
0 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,43 @@ | ||
const express = require("express"); | ||
const app = express(); | ||
const bodyParser = require("body-parser"); | ||
const https = require("https"); | ||
|
||
app.use(bodyParser.urlencoded({ extended: true })); | ||
|
||
app.get("/", function (req, res) { | ||
res.sendFile(__dirname + "/index.html"); | ||
}); | ||
|
||
app.post("/", function (req, res) { | ||
const query = req.body.cityName; | ||
const appid = "c713782c5fafb9656ed329673c4b77f7"; | ||
const url = | ||
"https://api.openweathermap.org/data/2.5/weather?q=" + | ||
query + | ||
"&appid=" + | ||
appid + | ||
"&units=metric"; | ||
https.get(url, function (response) { | ||
console.log(response.statusCode); | ||
|
||
response.on("data", function (data) { | ||
const weatherData = JSON.parse(data); | ||
const temp = weatherData.main.temp; | ||
const weatherDesc = weatherData.weather[0].description; | ||
const icon = weatherData.weather[0].icon; | ||
const imageUrl = "http://openweathermap.org/img/wn/" + icon + "@2x.png"; | ||
|
||
res.write("<p>The weather curently is " + weatherDesc + "</p>"); | ||
res.write( | ||
"<h1>The temperature in " + query + " is</h1>" + temp + "degree celsius" | ||
); | ||
res.write("<img src=" + imageUrl + ">"); | ||
res.send(); | ||
}); | ||
}); | ||
}); | ||
|
||
app.listen(3000, function () { | ||
console.log("server started on port 3000."); | ||
}); |
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,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Weather app</title> | ||
</head> | ||
<body> | ||
<form action="/" method="post"> | ||
<label for="cityInput">City Name</label> | ||
<input | ||
id="cityInput" | ||
type="text" | ||
name="cityName" | ||
placeholder="City Name" | ||
/> | ||
<button type="submit">GO</button> | ||
</form> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.