I'm having an issue serving a simple static html file with Express on a Cloud9 server.
My file structure is simply:
/workspace
/public
And here's my code, I get a Cannot GET/ (screenshot) when previewing in the browser.
static.js (located in the C9 workspace):
var http = require('http');
var path = require('path');
var express = require('express');
var app = express();
app.use(express.static(path.join(__dirname, '/public')));
http.createServer(app).listen(8080);
static.html (located in /public):
<!doctype html>
<html>
<body>
<p>Hello World!</p>
</body>
</html>
I know the server's listening on the right port, because the preview works when I write directly to the response stream using Express, like this:
app.use(function(request, response) {
response.end("Hello world!\n");
});
http.createServer(app).listen(8080);
Apologies for the simplicity of the request, I just pared everything down to understand the fundamental reason I'm seeing "Cannot GET/".
Thanks for your help.
renaming the file from static.html to index.html will work