This project is a minimal yet fully functional web server made from scratch in go programming language and this web server is built on top of golang's built-in "net/http" package
- Dynamic route handling (
/page1
,/page2
) - Static file serving (e.g., HTML, CSS, JS) from the
public/
directory - Dynamic API proxying using a public API (catfact.ninja)
- HTTPS support with self-signed certificates (
cert.pem
andkey.pem
) that enables TLS encryption - Web server works with http1.1 protocol
- Go 1.25.1+ installed
- (Optional) run following command in terminal for generating local TLS certificates
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes
git clone https://github.com/neelkumar01/webserver.git
cd webserver/myserver
go run main.go
webserver/
βββ myserver/
βββ public/ # Static files directory
β βββ about/ # Served at /about/
β β βββ index.html
β β βββ style.css
β βββ root/ # Served at /
β βββ index.html
β βββ style.css
βββ cert.pem # TLS certificate (for HTTPS)
βββ key.pem # TLS private key
βββ go.mod # Go module file
βββ main.go # Main application entry point
The server listens on port 9999 for https
https://localhost:9999/
No external dependencies are used. All logic is built using Go's standard library:
- net/http
- fmt
- io
- log