// Import modules
var connect = require('connect');
var http = require('http');
var serveStatic = require('serve-static');

// Create middleware functions, from nodeJS, to set up server
var app = connect();
app.use(serveStatic('./dist'));
app.use(serveStatic('./'));

// Start server
console.log('Starting webserver on http://localhost:8080/');
http.createServer(app).listen(8080);

@@ -115,16 +115,66 @@
 tatic');
+%0Avar fs = require('fs');%0Avar url = require('url');
 %0A%0A// Cre
@@ -311,16 +311,1050 @@
 ./'));%0A%0A
+// Map all the expected SPA (Single Page App.) URLs to the root index.html%0Aapp.use(function (req, res, next) %7B%0A  var reqUri = url.parse(req.url);%0A  // Brainstorming correct regex to cover all valid URLs in the SPA.%0A  // var regex = /%5E%5C/%5B0-9%5D+/%0A  // var regex_views = /%5E%5C/(choose-video%7Cwatch-video%7Csave-notes)$/%0A  // var regex_views_with_search = /%5E%5C/(choose-video(%5C/%5Cw+)*%7Cwatch-video%7Csave-notes)$/%0A  // var regex_youtube = /%5Ehttp://(?:www%5C.)?youtu(?:be%5C.com/watch%5C?v=%7C%5C.be/)(%5B%5Cw%5C-%5D+)(&(amp;)?%5B%5Cw%5C?=%5D*)?$/%0A  // regex = regex;%0A  // if (regex.test(requestURI.pathname)) %7B%0A  if (/%5E%5C/%5B0-9%5D+/.test(reqUri.pathname)) %7B%0A    fs.readFile('./dist/index.html', %7B encoding: 'utf8' %7D, function (err, data) %7B%0A      if (err) %7B%0A        throw err;%0A      %7D%0A      res.statusCode = 200;%0A      res.setHeader('Content-Type', 'text/html');%0A      res.setHeader('Content-Length', data.length);%0A      res.write(data, 'utf8', function (err) %7B%0A        if (err) %7B%0A          throw err;%0A        %7D%0A        res.end();%0A      %7D);%0A    %7D);%0A  %7D else %7B%0A    next();%0A  %7D%0A%7D);%0A%0A
 // Start

Add lines for another app.use() for coveringall expected URLs to be used in the SPA (Single Page App). Tried to come up with a regex to replace the basic regex on line 23. Function was written by Chad Killingsworth as an in-class example, in the msu-calendar project.