Starter net/http server
This commit is contained in:
parent
f7ac4dabf3
commit
18c67410d3
20
main.go
Normal file
20
main.go
Normal 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)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user