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 {
case http.MethodGet:
// serve upload page for receive
tmpl, err := template.New("index").Parse(web.UploadPage)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// 获取当前设备名称
err = tmpl.Execute(w, config.G.DeviceName)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
// tmpl, err := template.New("index").Parse(web.UploadPage)
// if err != nil {
// http.Error(w, err.Error(), http.StatusInternalServerError)
// return
// }
// // 获取当前设备名称
// err = tmpl.Execute(w, config.G.DeviceName)
// if err != nil {
// http.Error(w, err.Error(), http.StatusInternalServerError)
// }
//
fmt.Fprintf(w, "%s:接收文件中...", r.Host)
case http.MethodPost:
// receive file and save
file, header, err := r.FormFile("file")

4
xgfs/main.go

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

BIN
xgfs/xtfs

Binary file not shown.
Loading…
Cancel
Save