Node JS - L1: Trend NXT Hands-On Assignments
Node JS - L1: Trend NXT Hands-On Assignments
Author: [email protected]
ToC:
d) Create a NodeJS based script file, that reads the names of the 2 files from the user (Use
process module; On stdin “data” event by using call-back accept the input from the user)
and reads the content of first file by using Read Stream API and writes in into second file
by using Write Stream API. If second file is available it should append the content. If not
it should create a new file and add the content to it.
Assignment 3 :
a) Create a user defined date module that can give you the current date and time.
b) Write a Node script file to display current Date & Time by using user defined date
module.
c) Write a Node script file to find out how many seconds are there in a year. How many
seconds are there in a century and writes the result into a file.
d) Create a daysTill custom module. It should be able to give you the number of days
till Christmas and the number of days till mother’s day. number of days till your
Birthday.(Hint : Subtract both the dates to get difference in no.of milliseconds)
Assignment 2:
a) Create a simple HTTP server that responds to requests with a simple HTML response.
(Hint : using http module)
b) Use fs.readFile to get hold of the about.html file. you can use __dirname to get the
current directory. In the fs call back use response.write() to write the file contents
to the response. Finally call response.end to send the index.html file content to the
user.
(Note: call-backs are asynchronous, you don't know how long it will take to start
reading the file, and Node will not wait. This means you will need to call
response.end in the fs call back or the response will be returned before the file has
been read.)