Last active
          December 28, 2015 10:29 
        
      - 
      
- 
        Save andreadipersio/7486919 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "flag" | |
| "net/http" | |
| ) | |
| var ( | |
| port int | |
| folder string | |
| ) | |
| func init() { | |
| flag.IntVar(&port, "port", 8080, "HTTP Server Port") | |
| flag.StringVar(&folder, "folder", "www", "Serve this folder") | |
| flag.Parse() | |
| } | |
| func main() { | |
| httpAddr := fmt.Sprintf(":%v", port) | |
| log.Printf("Listening to %v", httpAddr) | |
| // http://golang.org/pkg/net/http/#FileServer | |
| http.Handle("/statics/", http.StripPrefix("/statics/", http.FileServer(http.Dir(folder)))) | |
| log.Fatal(http.ListenAndServe(httpAddr, nil)) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Nice and clean, thank you