Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeepx authored Jul 12, 2020
1 parent 4c81a92 commit 29158ed
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
54 changes: 54 additions & 0 deletions index.html
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>
41 changes: 41 additions & 0 deletions index.js
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()

0 comments on commit 29158ed

Please sign in to comment.