Skip to content

Instantly share code, notes, and snippets.

@LautaroJayat
Created January 30, 2020 18:38
Show Gist options
  • Save LautaroJayat/b6d120ff7e7817c75fd073157c35e730 to your computer and use it in GitHub Desktop.
Save LautaroJayat/b6d120ff7e7817c75fd073157c35e730 to your computer and use it in GitHub Desktop.
const ctrl = require('./controllers/controllers');
const app = (req, res) => {
const URL = req.url;
// What we say when the request method isnt GET
if (req.method !== 'GET') {
ctrl.forInvalidMethod(req, res);
}
// Handler to serve index.html
if (URL === '/') {
ctrl.forIndex(req, res);
}
// Handler to serve stylesheets
if (URL.indexOf('.css') > 0) {
ctrl.forCSS(req, res);
}
// Handle to serve our video
if (URL.split('.')[1] === 'mp4') {
ctrl.forVideo(req, res);
}
}
module.exports = app;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment