- serverssl.js
- index.html
Last active
June 19, 2017 00:15
-
-
Save rpragana/cab9b0c65b09876988133d7c2c6d8936 to your computer and use it in GitHub Desktop.
express-https
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<h1>Servidor web seguro (ssl)</h1> | |
<p>Este servidor Node/Express usa https</p> | |
<script> | |
function notifyMe() { | |
// Let's check if the browser supports notifications | |
if (!("Notification" in window)) { | |
alert("This browser does not support desktop notification"); | |
} | |
// Let's check whether notification permissions have already been granted | |
else if (Notification.permission === "granted") { | |
// If it's okay let's create a notification | |
var notification = new Notification("Hi there!"); | |
} | |
// Otherwise, we need to ask the user for permission | |
else if (Notification.permission !== "denied") { | |
Notification.requestPermission(function (permission) { | |
// If the user accepts, let's create a notification | |
if (permission === "granted") { | |
var notification = new Notification("Hi there!"); | |
} | |
}); | |
} | |
// At last, if the user has denied notifications, and you | |
// want to be respectful there is no need to bother them any more. | |
} | |
notifyMe() | |
</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
#!/usr/bin/env nodemon | |
var fs = require('fs'); | |
var https = require('https'); | |
var express = require('express'); | |
var app = express() | |
app.use(express.static(__dirname + '/')); | |
https.createServer({ | |
key: fs.readFileSync('sslcert/key.pem'), | |
cert: fs.readFileSync('sslcert/cert.pem') | |
}, app).listen(7700); | |
console.log('Aponte seu navegador para https://localhost:7700/'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment