public
Created

  • Download Gist
jafoo.js
JavaScript
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
var cini = require('cinister');
 
var make_message = function (name, type) {
type = type.toUpperCase();
var html = name + ' is ' + type.toUpperCase();
if (type === 'GOOD') {
return '<h1>' + html + '</h1>';
}
else if (type === 'BAD') {
return '<h2>' + html + '</h2>';
}
else {
return '<h3>' + html + '</h3>';
}
};
 
var index_html = '<form method="GET" action="message">' +
' <input type="text" name="name" /> ' +
' <input type="hidden" name="type" value="good" /> ' +
' <input type="submit" />' +
'</form> ' +
'<form method="GET" action="message">' +
' <input type="text" name="name" /> ' +
' <input type="submit" />' +
' <input type="hidden" name="type" value="bad" /> ' +
'</form> ' +
'<form method="GET" action="message">' +
' <input type="text" name="name" /> ' +
' <input type="submit" />' +
' <input type="hidden" name="type" value="ugly" /> ' +
'</form> ';
cini.port(9000);
cini.get('/', function () { return index_html; });
cini.get('message', function (params) {
if (params.name && params.type) {
return make_message(params.name, params.type);
}
else {
return '<b>None found</b>';
}
});
cini.start();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.