-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
95 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,54 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>See Dogs</title> | ||
<!-- Required meta tags --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
|
||
<!-- Bootstrap CSS --> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" | ||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | ||
|
||
<style> | ||
img { | ||
border: 42px solid rgba(0, 0, 0, 0.9); | ||
} | ||
|
||
@media only screen and (max-width: 600px) { | ||
img { | ||
border: 22px solid rgba(0, 0, 0, 0.9); | ||
} | ||
} | ||
|
||
@media only screen and (max-width: 100px) { | ||
img { | ||
border: 10px solid rgba(0, 0, 0, 0.9); | ||
} | ||
} | ||
</style> | ||
|
||
</head> | ||
|
||
<body class="bg-light"> | ||
|
||
<div class="container mt-5 p-2"> | ||
<!-- <img src="" class="rounded " alt="..."> --> | ||
<img src="{%IMAGE%}" class="img-fluid d-block mx-auto" alt="Responsive image"> | ||
</div> | ||
|
||
<!-- Optional JavaScript --> | ||
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | ||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" | ||
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"> | ||
</script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" | ||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"> | ||
</script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" | ||
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"> | ||
</script> | ||
</body> | ||
|
||
</html> |
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,41 @@ | ||
const server = require("http").createServer(); | ||
const fs = require("fs"); | ||
const superagent = require('superagent'); | ||
|
||
|
||
let temp = fs.readFileSync(`${__dirname}/index.html`, "utf-8"); | ||
|
||
const Replace = (tmp, data) => { | ||
let output = tmp.replace(/{%IMAGE%}/g, data); | ||
return output; | ||
} | ||
|
||
server.on("request", (req, res) => { | ||
const path = req.url; | ||
if (path === "/" || path === "/home" || path === "/index") { | ||
res.writeHead(200); | ||
res.end("Hello") | ||
|
||
} else if (path === "/dogs") { | ||
res.writeHead(200, { | ||
"Content-type": "text/html" | ||
}); | ||
|
||
superagent | ||
.get("https://dog.ceo/api/breeds/image/random") | ||
.end((err, img) => { | ||
|
||
let page = Replace(temp, img.body.message); | ||
res.end(page) | ||
|
||
}) | ||
|
||
} else { | ||
res.writeHead(404); | ||
res.end("page not found") | ||
|
||
} | ||
|
||
}) | ||
|
||
server.listen() |