feat: add HTTP file server with beautiful file browser UI
This commit is contained in:
+14
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"ftp-server/config"
|
||||
ftpserver "ftp-server/ftp"
|
||||
httpfileserver "ftp-server/httpfile"
|
||||
webserver "ftp-server/web"
|
||||
)
|
||||
|
||||
@@ -30,6 +31,9 @@ func main() {
|
||||
fmt.Printf("OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
|
||||
fmt.Printf("FTP Port: %d\n", cfg.FTP.Port)
|
||||
fmt.Printf("Web Admin: http://127.0.0.1:%d\n", cfg.Web.Port)
|
||||
if cfg.HTTPFile.Enable {
|
||||
fmt.Printf("HTTP Files: http://127.0.0.1:%d\n", cfg.HTTPFile.Port)
|
||||
}
|
||||
fmt.Printf("Admin User: %s\n", cfg.Admin.Username)
|
||||
fmt.Printf("Root Dir: %s\n", cfg.FTP.RootDir)
|
||||
fmt.Println("======================================")
|
||||
@@ -53,6 +57,16 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
// Start HTTP file server
|
||||
if cfg.HTTPFile.Enable {
|
||||
fileSrv := httpfileserver.NewServer(cfg)
|
||||
go func() {
|
||||
if err := fileSrv.Start(); err != nil {
|
||||
log.Fatalf("Failed to start HTTP file server: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Wait for termination signal
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
Reference in New Issue
Block a user