Skip to content

Instantly share code, notes, and snippets.

@ryansobol
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save ryansobol/3f86ee63034e321c14d4 to your computer and use it in GitHub Desktop.

Select an option

Save ryansobol/3f86ee63034e321c14d4 to your computer and use it in GitHub Desktop.

Revisions

  1. ryansobol revised this gist Mar 23, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ var url = require('url');
    http.createServer(function(request, response) {
    var pathname = __dirname + url.parse(request.url).pathname;

    fs.exists(pathname,function(exists) {
    fs.exists(pathname, function(exists) {
    if (exists) {
    fs.readFile('index.html', function(err, content) {
    response.end(content);
  2. ryansobol revised this gist Mar 23, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -8,11 +8,11 @@ http.createServer(function(request, response) {

    fs.exists(pathname,function(exists) {
    if (exists) {
    fs.readFile('index.html', function(err, content) {
    response.end(content);
    fs.readFile('index.html', function(err, content) {
    response.end(content);
    });
    } else {
    response.writeHead(404, { "Content-Type": "text/html" });
    response.writeHead(404, { "Content-Type": "text/html" });
    response.end("<h1>404 File Not Found</h1>");
    }
    });
  3. ryansobol revised this gist Mar 23, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -8,11 +8,11 @@ http.createServer(function(request, response) {

    fs.exists(pathname,function(exists) {
    if (exists) {
    fs.readFile('index.html', function(err, content) {
    fs.readFile('index.html', function(err, content) {
    response.end(content);
    });
    } else {
    response.writeHead(404, { "Content-Type": "text/html" });
    response.writeHead(404, { "Content-Type": "text/html" });
    response.end("<h1>404 File Not Found</h1>");
    }
    });
  4. ryansobol revised this gist Mar 23, 2015. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -7,13 +7,13 @@ http.createServer(function(request, response) {
    var pathname = __dirname + url.parse(request.url).pathname;

    fs.exists(pathname,function(exists) {
    if (exists) {
    fs.readFile('index.html', function(err, content) {
    response.end(content);
    if (exists) {
    fs.readFile('index.html', function(err, content) {
    response.end(content);
    });
    } else {
    response.writeHead(404, { "Content-Type": "text/html" });
    } else {
    response.writeHead(404, { "Content-Type": "text/html" });
    response.end("<h1>404 File Not Found</h1>");
    }
    }
    });
    }).listen(8080);
  5. ryansobol revised this gist Mar 23, 2015. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -4,16 +4,16 @@ var fs = require('fs');
    var url = require('url');

    http.createServer(function(request, response) {
    var pathname = __dirname + url.parse(request.url).pathname;
    fs.exists(pathname,function(exists) {
    if (exists) {
    fs.readFile('index.html', function(err, content) {
    response.end(content);
    });
    } else {
    response.writeHead(404, { "Content-Type": "text/html" });
    response.end("<h1>404 File Not Found</h1>");
    }
    });
    var pathname = __dirname + url.parse(request.url).pathname;
    fs.exists(pathname,function(exists) {
    if (exists) {
    fs.readFile('index.html', function(err, content) {
    response.end(content);
    });
    } else {
    response.writeHead(404, { "Content-Type": "text/html" });
    response.end("<h1>404 File Not Found</h1>");
    }
    });
    }).listen(8080);
  6. ryansobol renamed this gist Mar 23, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. ryansobol created this gist Mar 23, 2015.
    19 changes: 19 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    // Load required module
    var http = require('http');
    var fs = require('fs');
    var url = require('url');

    http.createServer(function(request, response) {
    var pathname = __dirname + url.parse(request.url).pathname;

    fs.exists(pathname,function(exists) {
    if (exists) {
    fs.readFile('index.html', function(err, content) {
    response.end(content);
    });
    } else {
    response.writeHead(404, { "Content-Type": "text/html" });
    response.end("<h1>404 File Not Found</h1>");
    }
    });
    }).listen(8080);