Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "io" |
| 6 | "net/http" |
| 7 | "os" |
| 8 | ) |
| 9 | |
| 10 | func main() { |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 11 | if len(os.Args) < 3 { |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 12 | fmt.Println("arg expected") |
| 13 | os.Exit(1) |
| 14 | } |
| 15 | |
adrianvillin | fbf5f2b | 2024-02-13 03:26:25 -0500 | [diff] [blame] | 16 | http.HandleFunc("/httpTestFile", func(w http.ResponseWriter, r *http.Request) { |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 17 | file, _ := os.Open("httpTestFile" + os.Args[2]) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 18 | defer file.Close() |
| 19 | io.Copy(w, file) |
| 20 | }) |
| 21 | err := http.ListenAndServe(os.Args[1], nil) |
| 22 | if err != nil { |
| 23 | fmt.Printf("%v\n", err) |
| 24 | os.Exit(1) |
| 25 | } |
| 26 | } |