-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
33 lines (27 loc) · 782 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"fmt"
"log"
"net/http"
"strings"
)
func handler(w http.ResponseWriter, r *http.Request) {
// Extract the path variable from the URLs
path := strings.TrimPrefix(r.URL.Path, "/")
// Generate an HTML response with tags
htmlResponse := fmt.Sprintf("<html><body><h1>Hello, It's Kubeday India 2023!!! and we are creating image version %s</h1></body></html>", path)
// Write the HTML response
w.Header().Set("Content-Type", "text/html")
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte(htmlResponse))
if err != nil {
log.Fatal(err)
}
}
func main() {
// Define a handler function
http.HandleFunc("/", handler)
// Start the HTTP server on port 9999
fmt.Println("Server listening on :9999")
log.Fatal(http.ListenAndServe(":9999", nil))
}