Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ func main() {
// Define command-line flags
var duration int
var showVersion bool
var port int

// Set default duration to 300 seconds
flag.IntVar(&duration, "t", 300, "Duration in seconds (default is 300 seconds)")
flag.IntVar(&port, "p", 8080, "Port for the HTTP server (default is 8080)")
flag.BoolVar(&showVersion, "v", false, "Show version")
flag.Parse()

Expand Down Expand Up @@ -75,16 +77,16 @@ func main() {
})

go func() {
fmt.Printf("Starting server on %s:8080...\n", ip)
if err := http.ListenAndServe(fmt.Sprintf("%s:8080", ip), nil); err != nil {
fmt.Printf("Starting server on %s:%d...\n", ip, port)
if err := http.ListenAndServe(fmt.Sprintf("%s:%d", ip, port), nil); err != nil {
fmt.Println("Error starting server:", err)
}
}()

// Generate the curl command
fmt.Printf("File %s is now available for download for %d seconds.\n", fileName, duration)
fmt.Printf("Use this curl command to download the file from another PC:\n")
fmt.Printf("curl -O http://%s:8080/%s/download/%s\n", ip, hostname, fileName)
fmt.Printf("curl -O http://%s:%d/%s/download/%s\n", ip, port, hostname, fileName)

// Block main goroutine to keep the server running
select {}
Expand Down