0% found this document useful (0 votes)
5 views8 pages

Back-End Web Development Using Nodejs

The document outlines the procedure for creating a back-end web application using NodeJS for Indian Dog registrations. It includes steps for setting up the server, creating a registration form in HTML, and handling POST requests to store and display data. The application successfully processes dog registration information and provides feedback to the user upon submission.

Uploaded by

akash.2211005
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)
5 views8 pages

Back-End Web Development Using Nodejs

The document outlines the procedure for creating a back-end web application using NodeJS for Indian Dog registrations. It includes steps for setting up the server, creating a registration form in HTML, and handling POST requests to store and display data. The application successfully processes dog registration information and provides feedback to the user upon submission.

Uploaded by

akash.2211005
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
You are on page 1/ 8

AKASH S (71812211005)

EX.NO: 08
BACK-END WEB DEVELOPMENT USING NODEJS
DATE:

AIM:
To design a back-end web application using NodeJS for Indian Dog registrations.

PROCEDURE:

1. Create a new folder for backend and navigate to it using ‘cd’


Install the necessary dependencies for the Node server:
npm init -y
npm install express body-parser

2. Use require function and import express and body-parser.


3. Create a post request using app.post
4. Store the data in a variable, using req.body
5. Print the data using console.log
AKASH S (71812211005)

6. Run the server using:


node ex8_server.js

CODE

FSD Ex 8.html

<html>
<head>
<title>Indian Dog Breeds Registration</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.form-container {
background-color: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 300px;
text-align: center;
}
h1 {
color: #8B4513;
AKASH S (71812211005)

font-size: 24px;
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
input,
select {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 14px;
}
button {
background-color: #8B4513;
/* Brown color */
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #A0522D;
}
.reset-button {
background-color: #ccc;
color: #333;
margin-left: 10px;
}
AKASH S (71812211005)

.reset-button:hover {
background-color: #bbb;
}
</style>
</head>

<body>

<!-- Dog Registration Form -->


<div class="form-container">
<h1>Indian Dog Breeds Registration</h1>
<form name="dogForm" action="http://localhost:3000/register-dog" method="POST">
<!-- Dog Name -->
<label for="dogName">Dog Name</label>
<input type="text" id="dogName" name="dogName" placeholder="Enter Dog Name"
required>

<!-- Breed Selection -->


<label for="breed">Breed</label>
<select id="breed" name="breed" required>
<option value="" disabled selected>Select Breed</option>
<option value="Rajapalayam">Rajapalayam</option>
<option value="Mudhol Hound">Mudhol Hound</option>
<option value="Indian Pariah">Indian Pariah</option>
<option value="Kanni">Kanni</option>
<option value="Chippiparai">Chippiparai</option>
<option value="Combai">Combai</option>
<option value="Rampur Hound">Rampur Hound</option>
<option value="Pandikona">Pandikona</option>
</select>

<!-- Age -->


<label for="age">Age</label>
<input type="number" id="age" name="age" placeholder="Enter Age (in years)" required>

<!-- Owner's Name -->


<label for="ownerName">Owner's Name</label>
AKASH S (71812211005)

<input type="text" id="ownerName" name="ownerName" placeholder="Enter Owner's Name"


required>

<!-- Contact Information -->


<label for="contact">Contact Number</label>
<input type="tel" id="contact" name="contact" placeholder="Enter Contact Number" required>

<!-- Submit and Reset Buttons -->


<div>
<button type="submit">Register Dog</button>
<button type="reset" class="reset-button">Reset</button>
</div>
</form>
</div>
</body>
</html>

Ex8_server.js

const express = require('express');


const bodyparser = require('body-parser');
const app = express();
const port = 8000;

app.use(bodyparser.urlencoded({ extended: false }));


app.post('/register-dog', (req, res) => {
const { dogName, breed, age, ownerName, contact } = req.body;
console.log('Received Dog Registration:', req.body);
res.send(`Thank you, ${ownerName}! Your ${breed} dog, ${dogName}, has been registered
successfully.`);
});
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
AKASH S (71812211005)

OUTPUT
AKASH S (71812211005)
AKASH S (71812211005)

INFERENCE
The form once submitted will send a POST request to the backend server. The sent data will be
received in the backend server and will process it and send a response back. The data is also displayed
in the server using console.log

RESULT:
Thus, back-end web application using NodeJS for Indian Dog registrations has been verified
and executed successfully.

You might also like