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