Initial Commit
This commit is contained in:
		
							
								
								
									
										27
									
								
								main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	args := os.Args[1:]
 | 
			
		||||
	port := "8080"
 | 
			
		||||
	if len(args) == 0 {
 | 
			
		||||
		log.Println("Usage: quickhttp <content-dir> [port]")
 | 
			
		||||
		os.Exit(1)
 | 
			
		||||
	}
 | 
			
		||||
	content_dir := args[0]
 | 
			
		||||
 | 
			
		||||
	if len(args) == 2 {
 | 
			
		||||
		port = args[1]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Public Views
 | 
			
		||||
	fs := http.FileServer(http.Dir(content_dir))
 | 
			
		||||
	http.Handle("/", fs)
 | 
			
		||||
	log.Println("Listening...")
 | 
			
		||||
	log.Fatal(http.ListenAndServe(":"+port, nil))
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user