-
-
Save Mobilpadde/0026aaf59cadaa72072b22df5496085f to your computer and use it in GitHub Desktop.
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
const express = require("express"); | |
const app = express(); | |
app.get("/", (req, res) => { | |
res.render("index.pug"); | |
}); | |
app.listen(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
// ... | |
module.exports = (uri => { | |
return new Promise((resolve, reject) => { | |
rp({ | |
uri: uri, | |
followAllRedirects: true, | |
resolveWithFullResponse: true | |
}).then(res => { | |
resolve(res.request.uri.href); | |
}).catch(reject); | |
}); | |
}); | |
// ... |
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
const express = require("express"); | |
const check = require("./lib/checker.js"); | |
const app = express(); | |
// ... |
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
// ... | |
const app = express(); | |
app.set("view engine", "pug"); | |
app.set("views", __dirname + "/views"); | |
// ... |
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
html | |
head | |
link(href="/main.css", rel="stylesheet") | |
body | |
#wrapper | |
input#url(type="text") | |
button#go Go Figure | |
h1#result | |
script(src="main.js") |
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
*{ | |
margin: 0; | |
padding: 0; | |
outline: none; | |
} | |
body{ | |
font: 14px/1.1 sans-serif; | |
margin: 0 auto | |
} | |
#wrapper{ | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
text-align: center; | |
} | |
#url, #go{ | |
padding: 5px; | |
font-size: 2em; | |
border: none; | |
border-bottom: 2px solid #c9f1f1; | |
} | |
#go{ | |
background: transparent; | |
border-radius: 2px 2px 0 2px; | |
transition: background 250ms ease-in; | |
} | |
#go:hover{ | |
background: rgba(201, 241, 241, 0.35); | |
} | |
#result{ | |
padding: 15px; | |
} |
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
"use strict" | |
window.addEventListener("load", () => { | |
const url = document.getElementById("url"); | |
const btn = document.getElementById("go"); | |
const res = document.getElementById("result"); | |
}); |
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
// ... | |
const res = document.getElementById("result"); | |
btn.addEventListener("click", () => { | |
fetch("/check/" + url.value, { | |
method: "post" | |
}) | |
.then(result => result.json()) | |
.then(uri => res.innerText = uri); | |
}); | |
// ... |
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
// ... | |
app.get("/", (req, res) => { | |
res.render("index.pug"); | |
}); | |
app.post("/check/:url(*)", (req, res) => { | |
check(req.params.url).then(result => { | |
res.json(result); | |
}); | |
}); | |
// ... |
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
const rp = require("request-promise"); | |
const Promise = require("bluebird"); |
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
// ... | |
const Promise = require("bluebird"); | |
module.exports = (uri => { | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment