25 lines
424 B
Go
25 lines
424 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
"fmt"
|
|
)
|
|
|
|
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
|
w.Write([]byte("<h1>Hello World!</h1>"))
|
|
}
|
|
|
|
func main() {
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = "3000"
|
|
}
|
|
|
|
fmt.Print("\nim run in http://127.0.0.1:", port)
|
|
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("/", indexHandler)
|
|
http.ListenAndServe(":"+port, mux)
|
|
}
|