Let's now go full circle and create a simple web application that allows to insert data into our table and also reads and displays the data that was entered.
We need to start a web server with two routes (one for displaying data, one for taking user input), and we need to pass user input to the database and database results to the webpage. Here is the application in one go:
'use strict'; var mysql = require('mysql'), http = require('http'), url = require('url'), querystring = require('querystring'); // Start a web server on port 8888. Requests go to function handleRequest http.createServer(handleRequest).listen(8888); // Function that handles http requests function handleRequest(request, response) ...