Using express.js to execute a function after receiving an http request?
<p>So I have an angular controller that successfully makes an http request after a button is pressed. I have a node.js server running which gets the request and then sends back <code>YOU HAVE SUCCEEDED! HTTP REQUEST RECEIVED!</code>. I want to execute a function when the request is received, but the function lives in a file inside a folder which is in <code>./Source/Server/test.js</code>.</p>

<p>How do I tell my server.js file to send the command to run the function???</p>

<p>server.js:</p>

<pre><code>var express = require('express');
var app = express();
var fs = require('fs');
app.use(express.static(__dirname + '/Source/Client/Templates'));
app.use(express.static(__dirname + '/'));
app.get('/', function (req, res) {
    res.sendFile('/Source/Client/Templates/Home.html', {root: __dirname });
});
app.get('/ThisIsATest', function (req, res) {
  res.send('YOU HAVE SUCCEEDED! HTTP REQUEST RECEIVED!')
})
app.listen(3000);
console.log("running at port 3000");
</code></pre>

<p>test.js:</p>

<pre><code>var run = require('./quickstart.js');
run.runQuickstart();
</code></pre>

<p>Controller:</p>

<pre><code>angular.module('DaycareApp').controller('WaitingListController', ['$scope', '$http', function($scope, $http){
    $scope.test = function() {
        $http.get('/ThisIsATest')
        .then(function(response) {
            alert(response.data);
        });
    };
}]);
</code></pre>