add flag for passing in directory to serve
This commit is contained in:
parent
3aef7abf9a
commit
6d30d6351a
5
main.go
5
main.go
@ -265,6 +265,7 @@ func main() {
|
|||||||
var watch = flag.Bool("w", false, "Enable 'watch' mode. Requires 'wdir' and 'wcmd'.")
|
var watch = flag.Bool("w", false, "Enable 'watch' mode. Requires 'wdir' and 'wcmd'.")
|
||||||
var watchDir = flag.String("wdir", "", "watch a directory for changes, run command when change happens.")
|
var watchDir = flag.String("wdir", "", "watch a directory for changes, run command when change happens.")
|
||||||
var watchCmd = flag.String("wcmd", "", "command to run when changes are detected in 'wdir'.")
|
var watchCmd = flag.String("wcmd", "", "command to run when changes are detected in 'wdir'.")
|
||||||
|
var watchSrv = flag.String("wsrv", "", "Serve static files from specified directory.")
|
||||||
var srvPort = flag.String("port", ":8080", "Port to serve the static files on.")
|
var srvPort = flag.String("port", ":8080", "Port to serve the static files on.")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@ -378,11 +379,11 @@ func main() {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// Start a http server and serve the static dir
|
// Start a http server and serve the static dir
|
||||||
log.Printf("listening on https://localhost%s", *srvPort)
|
log.Printf("serving '%s' on https://localhost%s", *watchSrv, *srvPort)
|
||||||
log.Fatal(
|
log.Fatal(
|
||||||
http.ListenAndServe(
|
http.ListenAndServe(
|
||||||
*srvPort,
|
*srvPort,
|
||||||
http.FileServer(http.Dir("static/")),
|
http.FileServer(http.Dir(*watchSrv)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user