Form submit with bootstrap and nodejs

Here is provided a simple code sample of how to place bootstrap form on your site and connect it with node js server.
//connect express
var express = require('express');
var path = require('path');
var ejs = require('ejs');
var partials = require('express-partials');
var app = express();

app.use(express.urlencoded({ extended: false }));
app.set('views', path.join(__dirname, '../views'));
app.set('view engine', 'ejs');

//top level routing
app.get('/', (req, res) => {
});'/submit_form', function(req, res){
    res.render('thanks.ejs', {body: req.body})

//start server
var http = require('http');

var port = 3000;
app.set('port', port);

var server = http.createServer(app);

<- start index.ejs -->
<form action="/submit_form" method="post" class="form-signin">
  <div class="form-group">
    <label for="email">Email</label>
    <input type="text" class="form-control" name="email" placeholder="Enter email">
  <div class="form-group">
    <label for="name">Message</label>
    <textarea type="text" class="form-control" name="message" placeholder="Enter message"></textarea>
  <button type="submit" class="btn btn-primary">Submit</button>
<- end index.ejs -->

<- start thanks.ejs--->
<end thanks.ejs --->
<- start layout.ejs --->
    <link rel="stylesheet" href="" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div class="container">
    <div class="content">
        <%-body -%>
<- end layout.ejs --->
Popular articles