-
-
Save SomeoneWeird/3951841 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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