Skip to content

Instantly share code, notes, and snippets.

@nishantmodak
Created April 6, 2014 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nishantmodak/10011404 to your computer and use it in GitHub Desktop.
Save nishantmodak/10011404 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net/http"
"time"
)
func main() {
http.HandleFunc("/", root)
log.Println("listening...")
err := http.ListenAndServe(":8080", nil)
if err != nil {
panic(err)
}
}
func root(w http.ResponseWriter, r *http.Request) {
// fmt.Fprint(w, rootForm)
renderTempalte(w, 'temp')
}
func renderTemplate(w http.ResponseWriter, tmpl string) {
t, _ := template.ParseFiles(tmpl + ".html")
t.Execute(w, p)
}
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello. The time is : " + time.Now().Format(time.RFC850))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment