What I want to do is serve the index.html file when the index route (i.e. localhost:3000) is called.
I use koa-router for routing, so my route looks like this:
app.all("/", function * (next){
//Send the file here
});
I tried to use koa-static like this:
var serve = require('koa-static');
app.all("/", function * (next){
serve("index.html");
});
But that didn't work. Then I tried to use co-views (I put the html file in the public directory now):
var views = require("co-views");
var render = views("public");
app.all("/", function * (next){
this.status = 200;
this.body = yield render("index.html");
});
But that didn't work.
So can anyone tell me what I have to do?