Logo

dev-resources.site

for different kinds of informations.

How web technology works? - Part 02

Published at
2/18/2024
Categories
learning
webtechnology
node
webserver
Author
amjadcp
Author
7 person written this
amjadcp
open
How web technology works? - Part 02

In this section, we will explore how to send data to a web server. We will be using the http library in Node.js to build our server.

Before moving on, ensure you're familiar with the concepts covered in Part 1, which you can find here: How web technology works? - Part 01

Create form in HTML

form.html

form.html - preview

HTML forms are commonly used to send data to a server. To begin, let's create an HTML form. We will be using the POST method to send data to the server. Please refer to the screenshot above for a better understanding of the form we will be using.

Create web-server using NodeJS

server.js-1

server.js-2

server.js-3

Here is a server that serves HTML files. If a request is made to the "/form" path, the server will return the form.html file. The client can then make a POST request to the "/submit" path with the form data, and the server will simply log the data to the console. If the client requests any other path, they will receive a "Not Found" message. Please refer to the screenshots below for further clarification.

1

The client requests "/form" using the GET method.

2

The client requests “/submit” using the POST method

3

The form data in the POST request.

4

The response for the POST request.

5

The server logs the POST request from the client.

Conclusion: Sending Data to the Server - More Than Just Forms

we explored sending data to a web server using an HTML form and Node.js. While this is a common and user-friendly approach, it's important to remember that it's just one piece of the puzzle.

Key Takeaways:

  1. Method Choice Matters: The best way to send data depends on your specific needs. Whether building a contact form, an e-commerce checkout, or an API, understanding different methods like forms, JSON bodies, URL parameters, and queries is crucial for optimal communication between clients and servers.

  2. Beyond Forms: While forms are great for user input, other methods offer more flexibility and power. JSON bodies are perfect for structured data exchange in APIs, while URL parameters and queries excel at passing smaller data chunks.

  3. Data's Final Destination: Ultimately, the server processes and stores the received data. Databases are a common choice for persistent storage, allowing easy retrieval and manipulation.

webserver Article's
30 articles in total
Favicon
Nginx Simplified: Technical Insights with Real-World Analogies
Favicon
Need assistance to solve an issue
Favicon
Installing Nginx Web Server on Linux: A Step-by-Step Guide
Favicon
Step-by-Step Guide: Setting Up Apache2 and Deploying an HTML Template on Ubuntu (Using Vagrant on a Local Machine)
Favicon
Path-Based Reverse Proxying with Caddy
Favicon
Transform Your Business with Our ERP CRM Software in Kolkata
Favicon
What is a web server ?
Favicon
Postmortem
Favicon
gondola: Why not use a lightweight and simple YAML-based reverse proxy?
Favicon
Uptime Kuma: Uptime von Services beobachten und tracken 🔎
Favicon
Nginx-Proxy-Manager: Leichtgewichtiger Reverse-Proxy 🌍
Favicon
Nginx Proxy Manager: Lightweight reverse proxy 🌍
Favicon
Uptime Kuma: Monitor and track the uptime of services 🔎
Favicon
OpenResty: The Overpowered Web Server Used by 40M Websites (that people rarely talk about)
Favicon
Installing a WebServer on Win Server 2019 VM
Favicon
HOW TO SECURE A WINDOWS SERVER WITH IIS AND AZURE NETWORK SECURITY FEATURES
Favicon
Web Sunucuları: İnternetin Temel Taşları
Favicon
Installing a WebServer on Win Server 2019 VM
Favicon
Advantages of Outsourcing Server Management
Favicon
Deploying a web server on the Linux virtual machine
Favicon
Should I use Nginx or Apache Server?
Favicon
Running a Secure Web Server on AWS EC2
Favicon
Trending In NGINX: Top Trends
Favicon
🚀How TCP Servers Are Designed to Handle Multiple Requests
Favicon
Why did Cloudflare Build its Own Reverse Proxy? - Pingora vs NGINX
Favicon
Planning my Linux Homelab
Favicon
Building a Web Server in Go
Favicon
🚀Unlocking the Power of NGINX - A Web Server Marvel! 🚀
Favicon
Local machine as a web server without public IP using Cloudflare tunnel(part-1)
Favicon
How web technology works? - Part 02

Featured ones: