Created
April 27, 2015 16:10
-
-
Save kopasetik/fa52b523a56374ef1cf2 to your computer and use it in GitHub Desktop.
Basic Form
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
doctype html | |
html | |
head | |
title Basic Form | |
body | |
h1 This is the form. | |
form(action="/basic-form", method="post") | |
.form-name | |
label(for="name") Name | |
input(type="text", id="name", value="Enter your name", name="name") | |
.form-phone | |
label(for="phone") Phone | |
input(type="tel", id="phone", name="phone") | |
.form-msg | |
label(for="msg") Message | |
textarea(id="msg", rows="5", name="msg") Just some filler text | |
.form-button | |
button(type="submit") Send that message! |
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"), | |
fs = require("fs"), | |
path = require("path"), | |
express = require("express"), | |
bodyParser = require("body-parser"), | |
multer = require("multer"); | |
var app = express(); | |
var server = http.createServer(app); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({extended: true})); | |
app.use(multer()); | |
app.set('views', './views'); | |
app.set('view engine', 'jade'); | |
app.route('/') | |
.get(function (req, res) { | |
res.render('index'); | |
res.end(); | |
}); | |
app.post('/basic-form', function (req, res) { | |
res.send(req.body); | |
res.end(); | |
}); | |
app.get('/tos', function (req, res) { | |
res.render('tos'); | |
res.end(); | |
}); | |
app.get('/deauth', function (req, res) { | |
res.render('deauth'); | |
res.end(); | |
}); | |
server.listen(process.env.PORT || 3000, process.env.IP || '0.0.0.0', function(){ | |
var addr = server.address(); | |
console.log('Server running at', addr.address + ':' + addr.port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment