This is a simple Go program that demonstrates the creation of an HTTP server using the net/http package. The program serves static files, handles a form submission, and responds to a basic "hello" endpoint.
- Static File Serving: The program serves static files located in the ./static directory.
- Form Handling: It handles a form submission at the /form endpoint. Upon receiving a POST request, the server parses the form data and responds with the submitted name and address.
- Hello Endpoint: The /hello endpoint responds with a "hello!" message for GET requests.
- Clone repo
git clone <repository-url>cd <repository-directory> - Run program
go run main.go - Access the server in your browser:
- To view the static files, open your browser and navigate to http://localhost:8080.
- To access the form, visit http://localhost:8080/form.
- To receive a "hello!" response, visit http://localhost:8080/hello.
This program uses the Go standard library and does not require any additional dependencies.
main.go: The main Go source code file containing the HTTP server implementation. static/: A directory containing static files that will be served by the server.