-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
28 lines (21 loc) · 847 Bytes
/
main.go
File metadata and controls
28 lines (21 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main
import (
"net/http"
"log"
"tskFileServer/fileServer"
"flag"
)
func main() {
flag.StringVar(&fileServer.ADDR, "addr", "", "[ip:port], such as: 0.0.0.0:80")
flag.StringVar(&fileServer.BASE_PATH, "dir", ".", "Directory to expose, such as: /tmp/share")
flag.Parse()
http.HandleFunc("/", fileServer.RouterHandler)
http.Handle("/file/", http.StripPrefix("/file/", http.FileServer(http.Dir(fileServer.BASE_PATH))))
http.HandleFunc("/download", fileServer.Download)
http.HandleFunc("/upload", fileServer.Upload)
http.HandleFunc("/mkdir", fileServer.Mkdir)
http.HandleFunc("/cmd/local", fileServer.CmdLocal)
http.HandleFunc("/cmd/ssh", fileServer.CmdSsh)
log.Printf("\nWill listen on: %s\nPath to expose: %s", fileServer.ADDR, fileServer.BASE_PATH)
log.Fatal(http.ListenAndServe(fileServer.ADDR, nil))
}