Skip to content

Making a To-Do List With flatiron.js (Story 2) ​

DANGER

The flatiron library is no more. So, other than reading stuff, there just isn't all that much relevant stuff, here.

This post continues the creation of a to-do list with flatiron.js.

Previous Stories in this Series ​

Ok. Easy and ugly. Create a file named index.html and create some HTML that shows a text input and a submit button. Change your server.js to return it for the GET / request. I did it like this.

javascript
// server.js

var session = require('connect').session
  , cookieParser = require('connect').cookieParser
  , flatiron = require('flatiron')
  , app = flatiron.app
  , fs = require('fs')
  ;

app.use(flatiron.plugins.http);

app.http.before.push(cookieParser('todo list secret'));
app.http.before.push(session());

app.router.get('/', function() {
  var self = this;
  fs.readFile('index.html', function(err, data) {
    if(err) {
      self.res.writeHead(404);
      self.res.end();
      return;
    }
    self.res.writeHead(200, {'Content-Type': 'text/html'});
    self.res.end(data);
  })
});

app.start(8090);

With my awesome HTML, my page looks like this.

story 2

Released under CC BY-NC-ND 4.0