Skip to content

Instantly share code, notes, and snippets.

@viettranx
Created September 29, 2018 09:03
Show Gist options
  • Save viettranx/75052c44fe8c3d172409dd8214622303 to your computer and use it in GitHub Desktop.
Save viettranx/75052c44fe8c3d172409dd8214622303 to your computer and use it in GitHub Desktop.
A simple web application - Golang
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprint(w, "<center><h1>Welcome to my page<h1></center>")
}
func main() {
http.HandleFunc("/", handler)
fmt.Println("Server is running...")
http.ListenAndServe("0.0.0.0:3000", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment