Add http-server exercise
This commit is contained in:
parent
1a36774ee3
commit
1f23019846
|
@ -0,0 +1,3 @@
|
|||
module httpserver
|
||||
|
||||
go 1.22.2
|
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func getRoot(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Printf("Received connection\n")
|
||||
fmt.Fprintln(w, "Hello!")
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", getRoot)
|
||||
|
||||
err := http.ListenAndServe(":8080", nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue