Skip to content

Commit

Permalink
Merge pull request #126 from Omm-Pani/main
Browse files Browse the repository at this point in the history
issue no.#46 resolved
  • Loading branch information
binayaksadangi authored Oct 11, 2022
2 parents 6e8d585 + 97827df commit 8e7e750
Show file tree
Hide file tree
Showing 429 changed files with 62,252 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Omm-Pani/app.js
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.");
});
21 changes: 21 additions & 0 deletions Omm-Pani/index.html
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>
12 changes: 12 additions & 0 deletions Omm-Pani/node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Omm-Pani/node_modules/.bin/mime.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Omm-Pani/node_modules/.bin/mime.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8e7e750

Please sign in to comment.