user3628240 user3628240 - 1 year ago 79
Javascript Question

localhost:8080 not working for node server

I recently tried to run node server.js, but for some reason the page is no longer loading, and the browser is just waiting indefinitely. This is the case for both safari and chrome. The code worked fine before and the page would load immediately, but for some reason it stopped working now (not sure if computer updated, or need to install a new version)

If anyone could help figure out why the server will not load it would be greatly appreciated.

my server.js file looks like:

var express = require('express');
var fundsapp = require('./fundsapp.js');
var app = express();

app.use('/js', express.static(__dirname + '/public/js'));
app.use('/libs', express.static(__dirname + '/public/libs'));
app.use('/css', express.static(__dirname + '/public/css'));
app.use('/views', express.static(__dirname + '/public/views'));

// app.use('/public/partials', express.static(__dirname + '/public/partials'));
// app.use('/public/js/controllers', express.static(__dirname + '/public/js/controllers'));
// app.use('/public/services', express.static(__dirname + '/public/js/services'))

app.get('/:cik/:startdate/:enddate/:startingtotal', function (req,res) {
// console.log(fundsapp.absolutedollarvalue(req.params.cik, req.params.startdate, req.params.enddate, req.params.startingtotal))

app.get('/api/returns', function(req,res) {
fundsapp.calculateReturns(req.query.startDate, req.query.endDate, res, req.query.cik, req.query.benchmark)

app.get('/api/adv', function(req,res) {
fundsapp.absolutedollarvalue(req.query.startDate, req.query.endDate, req.query.cik, req.query.startingAmount, res)

//app.get('*', function(req, res) {
// res.sendfile('./public/index.html');
app.get('/', function(req, res) {
res.sendFile('public/index.html' , { root : __dirname});

app.listen(8080, function() {
console.log("Listening on port 8080")

my index.html file is below:

<!-- public/index.html -->
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<base href="/">


<!-- CSS -->
<!-- <link rel="stylesheet" href="libs/bootstrap/dist/css/bootstrap.min.css"> -->
<link href="//" rel="stylesheet">
<link rel="stylesheet" href="libs/angular-bootstrap/ui-bootstrap-csp.css">
<link rel="stylesheet" href="css/style.css"> <!-- custom styles -->
<link rel="stylesheet" href="libs/angular-chart.js/dist/angular-chart.css">
<link rel="stylesheet" href="libs/angular-ui-grid/ui-grid.min.css">
<link rel="stylesheet" href="">

<!-- JS -->
<script src="libs/angular/angular.min.js"></script>
<script src="libs/angular-route/angular-route.min.js"></script>
<script src="libs/Chart.js/Chart.js"></script>
<script src="libs/angular-chart.js/dist/angular-chart.min.js"></script>
<script src="//"></script>
<script src="libs/angular-ui-grid/ui-grid.min.js"></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>

<script src="js/controllers/MainCtrl.js"></script>
<script src="js/controllers/TestCtrl.js"></script>
<script src="js/controllers/AdvCtrl.js"></script>
<script src="js/controllers/ReturnsCtrl.js"></script>
<script src="js/appRoutes.js"></script>
<script src="js/app.js"></script>
<script src="js/config.js"></script>
<body ng-app="alphaApp" ng-controller="TestController">
<div class="container">

<!-- HEADER -->
<nav class="navbar navbar-inverse">
<div class="navbar-header">
<a class="navbar-brand" href="/">Home</a>

<ul class="nav navbar-nav">
<li><a href="/returns">Returns</a></li>
<li><a href="/adv">Absolute Returns</a></li>

<div ng-view></div>


If any additional information would be helpful please let me know. I'm confused why all of a sudden it stopped loading. I tried uninstalling and reinstalling node, npm, express, and bower to no avail.

Thanks for any help!

It looks like from the index.html file it is trying to access the libs folder which I no longer see in the folder. Is there an easy way to install a libs folder filled with the angular files?

Answer Source

Looks like you are referencing the libs folder here:

<script src="libs/angular/angular.min.js"></script>
<script src="libs/angular-route/angular-route.min.js"></script>
<script src="libs/Chart.js/Chart.js"></script>

Why don't you change these lines to wherever your vendor js files are?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download