Skip to content

Instantly share code, notes, and snippets.

@SomeoneWeird
Forked from dileephell/form submissi
Created October 25, 2012 10:21
Show Gist options
  • Save SomeoneWeird/3951841 to your computer and use it in GitHub Desktop.
Save SomeoneWeird/3951841 to your computer and use it in GitHub Desktop.
var http = require('http');
var express = require('express');
var ejs = require('ejs');
var app = express();
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.get('/', function(req, res) {
res.render('index.ejs', {
layout: false
});
});
app.post('/formhandler', function(req, res) {
console.log("[200] " + req.method + " to " + req.url);
console.log("Body data: ");
console.log(JSON.stringify(req.body));
});
app.configure(function() {
app.set('views', __dirname + '/files');
app.use(app.router);
app.use(express.static(__dirname + '/public'));
app.use(express.errorHandler({
dumpExceptions: true,
showStack: true
}));
});
app.listen(8098);
// create a directory called public, then create a directory inside that called css, then add this file in there and put your css in here
// add this file to /files/index.ejs
<html>
<head>
<link href="/css/index.css" rel="stylesheet" type="text/css" />
<title>Hello Noder!</title>
</head>
<body>
<h1>Welcome Noder, who are you?</h1>
<form enctype="application/x-www-form-urlencoded" action="/formhandler">
Name: <input type="text" name="username" value="" /><br />
Age: <input type="text" name="userage" value="" /><br />
<input type="submit" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment