A simple web server implemented in Go, serving static files and handling basic HTTP requests.
WebServer-with-Go/
|-- static/
| |-- index.html
| |-- form.html
|-- README.md
|-- main.go
|-- go.mod
This repository contains a basic implementation of a web server using the Go programming language. The server serves static HTML files located in the static/
directory and handles basic HTTP requests.
-
Serving Static Files: The web server serves static HTML files such as
index.html
andform.html
from thestatic/
directory. -
Hello Handler: Accessing the path
/hello
with a GET request returns a "Hello there" message. -
Form Handler: Accessing the path
/form
with a POST request displays a "POST Request Successful" message and prints form data (name and address) submitted by the client.
-
Clone this repository to your local machine:
git clone https://github.com/your-username/WebServer-with-Go.git
-
Navigate to the project directory:
cd WebServer-with-Go
-
Build and run the server:
go run main.go
-
Open your web browser and visit http://localhost:8080 to access the web server. You can also try accessing http://localhost:8080/hello and http://localhost:8080/form to see the different handlers in action.
This web server is a basic example of serving static files and handling HTTP requests using Go. You can use this project as a starting point to build more complex web applications or APIs.
Feel free to modify or expand upon the code to include additional features, improve error handling, or integrate with other parts of your application.
Contributions are welcome! If you have any improvements or additional features you'd like to add, please feel free to fork this repository and submit a pull request.
This project is licensed under the MIT License.