YaK:: starter http.ListenAndServe [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
[mega_changes]
[photos]

starter http.ListenAndServe

  1 package main
  2
  3 import (
  4   "os"
  5   "fmt"
  6   "net/http"
  8 )
 11
 12 func home(w http.ResponseWriter, r *http.Request) {
 13   fmt.Fprintf(w, "Hello World!")
 14 }
 15
 16 func main() {
 17   port := os.Args[1]
 18   http.HandleFunc("/", home)
 19   http.ListenAndServe("127.0.0.1:" + port, nil)
 20 }
(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2012-12-15)       [Login]
(No back references.)