Making a To-Do List With flatiron.js (Story 2) Thursday, January 12th 2012
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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.