Pete
Pete

Reputation: 113

Cannot GET /test.html - node.js - javascript

I'm trying to learn Angular.js and I'm trying to setup my development environment (as described in Pro Angularjs) and I'm having problems. Others have experienced similar problems but even after looking at some of the solutions I still can't get mine to work. Since I'm new to all this it's probably something very basic and your help is appreciated.

My setup is:

In my "nodejs" directory I have a directory called "angularjs" and a file called "server.js" whose contents are shown below:

var connect = require('connect'),
    serveStatic = require('serve-static');

var app = connect();

app.use(serveStatic("/angularjs"));
app.listen(5000);

In my "angularjs" folder I have a file called "test.html" with contents:

    <!DOCTYPE html>
<html ng-app>
<head>
    <title>First Test</title>
    <script src="angular.js"></script>
    <link href="bootstrap.css" rel="stylesheet" />
    <link href="bootstrap-theme.css" rel="stylesheet" />
</head>
<body>
    <div class="btn btn-default">{{"AngularJS"}}</div>
    <div class="btn btn-success">Bootstrap</div>
</body>
</html>

When I run it I get "Cannot GET /test.html". Any help is appeciated.

Thanks,

Pete

Upvotes: 1

Views: 1404

Answers (1)

Yuri Zarubin
Yuri Zarubin

Reputation: 11677

Try

app.use(serveStatic("./angularjs"));

Upvotes: 2

Related Questions