Skip to content

Instantly share code, notes, and snippets.

@WolvenSpirit
Created December 21, 2018 19:40
Show Gist options
  • Save WolvenSpirit/b26a0143f55a3a19c20cd4ca6a937101 to your computer and use it in GitHub Desktop.
Save WolvenSpirit/b26a0143f55a3a19c20cd4ca6a937101 to your computer and use it in GitHub Desktop.

Revisions

  1. WolvenSpirit created this gist Dec 21, 2018.
    22 changes: 22 additions & 0 deletions basic_server.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    package main

    import ("fmt"
    "net/http")

    func server(){
    http.HandleFunc("/",index_handler)
    http.HandleFunc("/links",links_handler)
    http.ListenAndServe("127.0.0.1:8000", nil)
    }
    // r reader points to request
    func index_handler(w http.ResponseWriter, r *http.Request){
    fmt.Fprintf(w,"Live...!")
    }

    func links_handler(w http.ResponseWriter, r *http.Request){
    fmt.Fprintf(w,"<a href=http://core.litedesign.net>core.litedesign.net</a>")
    }

    func main(){
    server()
    }