Skip to content

Instantly share code, notes, and snippets.

@deanhume
Last active March 16, 2018 11:28
Show Gist options
  • Save deanhume/421d08aa08c127ddd0df4c49149f0daa to your computer and use it in GitHub Desktop.
Save deanhume/421d08aa08c127ddd0df4c49149f0daa to your computer and use it in GitHub Desktop.
HTTP/2 Server
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.');
});
@alicchello
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment