0% found this document useful (0 votes)
37 views3 pages

Practice Questions - Creating Server

Uploaded by

akramshaik2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views3 pages

Practice Questions - Creating Server

Uploaded by

akramshaik2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

NodeJs Creating Server

1. Simple HTTP Server

Question: Write a [Link] script to create a simple HTTP server that responds with "Hello,
World!".

2. Serve JSON Data

Question: Create an HTTP server that responds with JSON data.

3. Serve HTML File

Question: Modify the server to serve an HTML file instead of plain text and if the file was not
found respond as “error in loading”.

4. Serve Different Responses Based on URL

Question: Create an HTTP server that returns different responses for /home and /about URLs
and if the URLs doesn’t found respond as “Page not found”.

5. Handling POST Requests

Question: Write a server that handles a POST request and returns the sent data in the response.

6. Serve JSON Based on Query Parameters

Question: Create an HTTP server that parses URL query parameters and returns them as JSON.

7. Redirect Requests

Question: Write an HTTP server that redirects requests from /old to /new and if request not
found respond as “Page not found”.
NodeJS Creating Server With Routes
1. Simple Route for Home Page

Question: Create a simple HTTP server with a route for the home page (/) and if the request not
found respond as “Page not found”.

2. Route for About Page

Question: Add a route to home page(/) for /about that returns "About Us" and if the request not
found respond as “Page not found”.

3. Route for Contact Page

Question: Add a route to home page(/) for /contact that returns "Contact Us" and if the request
not found respond as “Page not found”.

4. Route with Query String Parameters

Question: Handle query string parameters for /greet?name=John and if the request not found
respond as “Page not found”.

5. Route for Products

Question: Create a /products route that responds with "Product List" and if the request not
found respond as “Page not found”.

6. Route for Services

Question: Add a /services route that responds with "Our Services" and if the request not found
respond as “Page not found”.

7. Handling Unknown Routes

Question: Add a fallback route for unknown paths that returns "404 - Page Not Found".

8. Route for /help Page

Question: Add a /help route that returns "Help Page".

9. Route for /blog

Question: Add a /blog route that returns "Blog Posts".

10. Route for /team

Question: Add a /team route that returns "Meet Our Team".

11. Route with URL Parameters (Path Variables)

Question: Create a /user/:id route that returns the user ID from the URL and if the request not
found respond as “Page not found”.

12. Route for Login Form (GET Request)

Question: Create a /login route that displays a simple login form.

13. Route with Dynamic Page Titles


Question: Create a /page/:title route that returns a page with a dynamic title.

14. Route for /gallery with HTML Response

Question: Create a /gallery route that returns an HTML response showing images.

15. Route for Showing Server Time

Question: Create a /time route that returns the current server time.

16. Route for FAQ Page

Question: Add a /faq route that returns an HTML list of frequently asked questions.

You might also like