Skip to content

Shashwat8127/Web-Server-Using-Golang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Web-Server-Using-Golang

I recently built a simple yet functional web server using Go (Golang) to strengthen my understanding of the net/http package. The server runs on port 8080 and handles multiple routes. The root route (/) displays a welcome message, while /form.html serves a contact form designed with modern HTML and CSS styling. When the form is submitted, the /form route processes the POST request, parses the submitted data using ParseForm(), and dynamically displays the user’s name and address. Additionally, I created a /hello route that handles GET requests and returns a friendly greeting. The server gracefully handles unsupported paths and methods by returning appropriate 404 errors. This project helped me practice Go’s HTTP routing, serving static files with http.ServeFile, handling form data securely, and implementing basic error handling. It’s a great foundation for building more advanced backend applications with Go.

Simple Go Web Server 🌐

This is a basic web server built using Golang. It demonstrates:

  • Serving static HTML files (like form.html)
  • Handling GET and POST requests
  • Parsing form data
  • Routing to different URLs

πŸš€ Features

βœ… Root route / β€” Displays a welcome message
βœ… /form.html β€” Serves a styled contact form
βœ… /form β€” Handles form submissions (POST) and displays submitted data
βœ… /hello β€” Responds to GET requests with Hello!
βœ… Graceful 404 handling for unsupported routes


πŸ“‚ Project structure

go-simple-webserver/ β”œβ”€β”€ main.go └── form.html

πŸ’» How to run

go run main.go

3️⃣ Open in browser:

http://localhost:8080/ β†’ Welcome message

http://localhost:8080/form.html β†’ Contact form

http://localhost:8080/hello β†’ Hello route

🌱 What I learned Setting up a basic Go web server

Creating custom route handlers

Parsing form data using ParseForm()

Serving static files using http.ServeFile

Basic error handling for HTTP servers

DEMO / OUTPUT: Coming soon / or run locally on localhost:8080.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published