Wednesday, February 7, 2018

Node JS Exercise

Click here to see original PDF Version of  Questions & Answers..

Create a simple http server and print “Welcome to Uki. I am yourname” when a request is sent to your server via the port 8000. (Note - Change different port numbers and check)


Using the file system module create a new file called ukinode.txt

3.1 Write a paragraph about Uki into that file


3.3 Append another paragraph about Uki and now serve the new file

3.4 Rename the file as ukinodejsexercise1.txt

3.5 Delete the file you created



4. Create two html files called head.html which is a web page which says ‘you have got head ‘ and tail.html which is a web page which says ‘you have got tail’ and save them in the same folder as your node.js files. Create a Node.js file that opens the requested file and returns the content to the client. If anything goes wrong, throw a 404 error.

If you have followed the correct steps you should see two different results when opening these two addresses:

http://localhost:8080/head.html - > You have got head

http://localhost:8080/tail.html -> You have got tail



5. Install the package “upper-case” using NPM and create a Node.js file that will convert the output "Uki is the best place to learn programming !" into upper-case letters.


6. Create an event handler function that will say “I bark when I see strangers !” when a "bark" event is fired.

7. Install “formidable” module using npm and make a web page in Node.js that lets the user upload files to your computer.

7.1 Save that uploaded file into your Documents directory.

8. Using the Nodemailer module create a server and send a mail to info@uki.life with the subject : “Testing my nodemailer module” , text: “This is easy !”

8.1 Now instead of text send a basic html formatted mail.

No comments:

Post a Comment