Created
January 26, 2020 20:46
-
-
Save LautaroJayat/29ea815dac22485db4dcb67ccf311cea to your computer and use it in GitHub Desktop.
App.js - important module
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 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); | |
| } | |
| if (URL.indexOf('.js') > 0) { | |
| ctrl.forJavascript(req, res); | |
| } | |
| if (URL.split('.')[1] === 'mp4') { | |
| ctrl.forVideo(req, res); | |
| } | |
| if (URL.split('.')[1] === 'mp3') { | |
| ctrl.forAudio(req, res); | |
| } | |
| } | |
| module.exports = app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment