Last active
March 16, 2018 11:28
-
-
Save deanhume/421d08aa08c127ddd0df4c49149f0daa to your computer and use it in GitHub Desktop.
HTTP/2 Server
This file contains hidden or 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 spdy = require('spdy'); | |
const express = require('express'); | |
const fs = require('mz/fs'); | |
const app = express(); | |
app.use(express.static('public')); | |
app.get('/home', (req, res) => { | |
fs.readFile('home.html') | |
.then(file => { | |
res.writeHead(200); | |
res.end(file); | |
}) | |
.catch(error => res.status(500).send(error.toString())); | |
}); | |
spdy.createServer({ | |
key: fs.readFileSync('./server.key'), | |
cert: fs.readFileSync('./server.crt') | |
}, app) | |
.listen(8000, (err) => { | |
if (err) { | |
throw new Error(err); | |
} | |
console.log('Listening on port: 8000.'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I have some images in my html but the server doesn't load them. Can you explain me why and how i can fix it?