|
@@ -3,6 +3,7 @@ package main
|
|
|
import (
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
+ "os"
|
|
|
)
|
|
|
|
|
|
func Index(w http.ResponseWriter, r *http.Request) {
|
|
@@ -35,15 +36,25 @@ func Update(w http.ResponseWriter, r *http.Request) {
|
|
|
fmt.Println(r.Method)
|
|
|
fmt.Println(r.Header)
|
|
|
|
|
|
- if r.URL.Path == "/fw.bin" {
|
|
|
- fmt.Println("Download update file...")
|
|
|
- http.ServeFile(w, r, `fw.bin`)
|
|
|
- }
|
|
|
+ fmt.Println(r.URL.Path)
|
|
|
+
|
|
|
+ fmt.Println("Download update file...")
|
|
|
+ // http.ServeFile(w, r, `fw.bin`)
|
|
|
+ // http.ServeFile(w, r, `E:\Greenstar\nSBS-ethernet-prime\bin\fw.bin`)
|
|
|
+
|
|
|
+ // if r.URL.Path == "/fw.bin" {
|
|
|
+ // fmt.Println("Download update file...")
|
|
|
+ // http.ServeFile(w, r, `fw.bin`)
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
func main() {
|
|
|
+ args := os.Args[1:]
|
|
|
+ var path = args[0]
|
|
|
+ var port = ":" + args[1]
|
|
|
+
|
|
|
fmt.Println("Starting HTTP server...")
|
|
|
http.HandleFunc("/index.html", Index)
|
|
|
- http.HandleFunc("/fw.bin", Update)
|
|
|
- http.ListenAndServe(":9000", nil)
|
|
|
+ http.HandleFunc(path, Update)
|
|
|
+ http.ListenAndServe(port, nil)
|
|
|
}
|