Starter net/http server

This commit is contained in:
pavak committed 2022-04-21 01:54:07 +05:30
1 parent f7ac4dabf3
commit 18c67410d3
1 file changed
+20
+20
View File
@@ -0,0 +1,20 @@
package main
import (
"fmt"
"net/http"
)
const port = ":5000"
func Home(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World!")
}
func main() {
http.HandleFunc("/", Home)
fmt.Printf("Starting web server on http://localhost%s\n", port)
_ = http.ListenAndServe(port, nil)
}