home‎ > ‎go‎ > ‎

Go Nano Http Server

A micro light Http Server, which I use for serving web contents internally, mainly for Java DOCs rendering, and my daughter uses it for HTML5, CSS3 and JS rendering during development.

I have installed it in my GOLANG PATH so that it can be run from anywhere. 

This code has been derived from golang.org sample.

  A Micro Lite Http File Server
  go build nano_httpd.go 
  ./nano_httpd --root="/home/ashish/ABLabs/AIAComponents"
package main

import (

func main() {
    inPort := flag.String("port","7070","Input Port Number, default 7070")
    flDir :=  flag.String("root", "~", "root content directory default is ~")
    httpPort := ":" + *inPort
    fmt.Printf("Port %s, Doc Root [%s]\n",httpPort,*flDir)
// Simple static webserver:
log.Fatal(http.ListenAndServe(httpPort, http.FileServer(http.Dir(*flDir))))

Find the file attached below:

Ashish Banerjee,
Jan 23, 2015, 10:17 PM