Last active
July 21, 2016 07:01
-
-
Save mariyadiminsky/614f5873683c373f5fbbac5b22d17100 to your computer and use it in GitHub Desktop.
This file contains 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
var http = require('http'); | |
// STEP #2.3 Let's configure two URLs to GET requests | |
// Uncomment below: | |
var bunnyServer = http.createServer(); | |
bunnyServer.on('request', function(req, res) { | |
// If it's a GET request: | |
if(req.method === 'GET') { | |
// and if the GET request is the homepage: | |
if (req.url === '/') { | |
res.setHeader('Content-Type', 'text/html'); | |
res.end('<html><body><h1>Bunny Server retrieved the Homepage!</h1><img src="http://weknowmemes.com/wp-content/uploads/2013/03/easter-bunny-meme-eggs.jpg"></body></html>') | |
} | |
// or if the GET request is to the blueberries page: | |
if (req.url === '/blueberries') { | |
res.setHeader('Content-Type', 'text/html'); | |
res.end('<html><body><h1>Bridagier Fluffykins loves Blueberries!</h1><img src="http://www.mememaker.net/static/images/memes/4347392.jpg"><br /><img src="https://notinthemoring.files.wordpress.com/2013/04/7c4d7863560049ead2527c0be32961a5.jpg"></body></html>') | |
} | |
} | |
}).listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment