Skip to content

Instantly share code, notes, and snippets.

@gevorg
Last active July 3, 2020 19:21
Show Gist options
  • Save gevorg/f6d8e3423f2bf88363c839f3873248e1 to your computer and use it in GitHub Desktop.
Save gevorg/f6d8e3423f2bf88363c839f3873248e1 to your computer and use it in GitHub Desktop.
Video Streaming
<video width="400" height="300" autoplay controls>
<source src="video.mp4" type="video/mp4">
</video>
<video width="400" height="300" autoplay controls>
<source src="video2.mp4" type="video/mp4">
</video>
const PORT = 8080;
const express = require('express');
const app = express();
const fs = require('fs');
app.get('/', function (req, res) {
res.sendFile(`${__dirname}/index.html`);
});
app.get('/video.mp4', function (req, res) {
res.sendFile(`${__dirname}/video.mp4`);
});
app.get('/video2.mp4', function (req, res) {
fs.readFile(`${__dirname}/video.mp4`, function read(err, data) {
res.send(data);
});
});
app.listen(PORT, function () {
console.log(`app listening on port ${PORT}!`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment