-
Book Overview & Buying
-
Table Of Contents
Node Cookbook: Second Edition
By :
If we want to be able to receive POST data, we have to instruct our server how to accept and handle a POST request. In PHP, we could access our POST values seamlessly with $_POST['fieldname'], because it would block until an array value was filled. Contrariwise, Node provides low-level interaction with the flow of HTTP data, allowing us to interface with the incoming message body as a stream, leaving it entirely up to the developer to turn that stream into usable data
Let's create a server.js file ready for our code, and an HTML file called form.html, that contains the following:
<form method=post> <input type=text name=userinput1><br> <input type=text name=userinput2><br> <input type=submit> </form>
For our purposes, we'll place form.html in the same folder as server.js. Though this is not generally a recommended practice, we should usually place our public code in a separate folder from our server code.
Change the font size
Change margin width
Change background colour