Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset = "UTF-8"/>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Bunny Server retrieved the Homepage!</h1>
<h2 class="see-me" style="color: white">If the css file is working you should see this.</h2>
<img src="http://weknowmemes.com/wp-content/uploads/2013/03/easter-bunny-meme-eggs.jpg"
var http = require('http');
var fs = require('fs');
// STEP #2.4 Let's serve actual files! 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 === '/') {
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 === '/') {
var http = require('http');
// STEP #2.2 Let's print the request headers from the request object. Uncomment below:
var bunnyServer = http.createServer();
bunnyServer.on('request', function(req, res) {
// printing the request headers!
console.log(req.headers);
// lets access the 'connection' property inside the headers object:
console.log("ACCESSING HEADER:", req.headers['connection']);
var http = require('http');
// STEP #2.1 Let's print the request url method
//from the request object. Uncomment below:
var bunnyServer = http.createServer();
bunnyServer.on('request', function(req, res) {
// printing the request url!
console.log(req.url);
// printing the request method!
console.log(req.method);
var http = require('http');
// STEP #2 Let's print the request object:
var bunnyServer = http.createServer();
bunnyServer.on('request', function(req, res) {
res.writeHead(200);
res.end('<html><body><h1>Bunny Server is live!</h1><img src="https://cdn.meme.am/instances/400x/55347780.jpg"></body></html>')
// printing the request object!
console.log(req);
if (req.url === '/') {
res.setHeader('Content-Type', 'text/html');
res.setHeader('BrigadierFluffykins', 'isAwesome');
res.setHeader('BunnyBunny', 'OhYeah');
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>')
}
// First require in the EventEmitter Object
var EventEmitter = require('events').EventEmitter;
// Create a new instance of the EventEmitter
var bunnyError = new EventEmitter();
// This is where you create your bunnyError event
// and create a callback that will be triggered when
// bunnyError is called
bunnyError.on('bunnyWarning', function(warning) {
console.log(`BUNNY WARNING: ${warning}`);
var http = require('http');
// STEP #1.5 Basic Server Continued...
var bunnyServer = http.createServer();
bunnyServer.on('request', function(req, res) {
res.writeHead(200);
res.end('<html><body><h1>Bunny Server is live!<br /><img src="https://cdn.meme.am/instances/400x/55347780.jpg"></h1></body></html>');
}).listen(3000);
.divs {
margin: auto;
padding: 30px;
width: 50%;
margin-bottom: 5px;
border: solid grey 1px;
}
#btn {
padding: 15px 63px;