Browse Source

调整get模式下的操作

master
453530270@qq.com 2 years ago
parent
commit
a4768175bd
  1. BIN
      xgfs/files/BIU_20240523_172749.zip
  2. 22
      xgfs/internal/handler/handler.go
  3. 4
      xgfs/main.go
  4. BIN
      xgfs/xtfs

BIN
xgfs/files/BIU_20240523_172749.zip

Binary file not shown.

22
xgfs/internal/handler/handler.go

@ -68,16 +68,18 @@ func ReceiveHandler(w http.ResponseWriter, r *http.Request) {
switch r.Method { switch r.Method {
case http.MethodGet: case http.MethodGet:
// serve upload page for receive // serve upload page for receive
tmpl, err := template.New("index").Parse(web.UploadPage) // tmpl, err := template.New("index").Parse(web.UploadPage)
if err != nil { // if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) // http.Error(w, err.Error(), http.StatusInternalServerError)
return // return
} // }
// 获取当前设备名称 // // 获取当前设备名称
err = tmpl.Execute(w, config.G.DeviceName) // err = tmpl.Execute(w, config.G.DeviceName)
if err != nil { // if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) // http.Error(w, err.Error(), http.StatusInternalServerError)
} // }
//
fmt.Fprintf(w, "%s:接收文件中...", r.Host)
case http.MethodPost: case http.MethodPost:
// receive file and save // receive file and save
file, header, err := r.FormFile("file") file, header, err := r.FormFile("file")

4
xgfs/main.go

@ -34,8 +34,8 @@ func receiveClient() error {
// 注释上面的局域网广播 // 注释上面的局域网广播
fmt.Println("xtfs run as receive role...") fmt.Println("xtfs run as receive role...")
// 显示状态等 // 显示状态等
http.HandleFunc("/", handler.ReceiveStatus) // http.HandleFunc("/", handler.ReceiveStatus)
// http.HandleFunc("/upload", handler.ReceiveHandler) http.HandleFunc("/", handler.ReceiveHandler)
// http.Handle("/static/", http.StripPrefix("/static/", // http.Handle("/static/", http.StripPrefix("/static/",
// http.FileServer(http.FS(web.StaticFs)))) // http.FileServer(http.FS(web.StaticFs))))

BIN
xgfs/xtfs

Binary file not shown.
Loading…
Cancel
Save