Skip to content

Instantly share code, notes, and snippets.

@kopasetik
Created April 27, 2015 16:10
Show Gist options
  • Save kopasetik/fa52b523a56374ef1cf2 to your computer and use it in GitHub Desktop.
Save kopasetik/fa52b523a56374ef1cf2 to your computer and use it in GitHub Desktop.
Basic Form
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!
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