Download handlers/fstree_instance.go from Xlnk/docker: direct link, hf CLI and curl.
- Browser
- Download file 757 Bytes
-
https://huggingface.co/spaces/Xlnk/docker/resolve/main/handlers/fstree_instance.go
- Command line
-
hf download hf://spaces/Xlnk/docker/handlers/fstree_instance.go
-
curl -L -o fstree_instance.go https://huggingface.co/spaces/Xlnk/docker/resolve/main/handlers/fstree_instance.go
757 Bytes
| package handlers | |
| import ( | |
| "io" | |
| "log" | |
| "net/http" | |
| "github.com/gorilla/mux" | |
| ) | |
| func fsTree(rw http.ResponseWriter, req *http.Request) { | |
| vars := mux.Vars(req) | |
| sessionId := vars["sessionId"] | |
| instanceName := vars["instanceName"] | |
| s, _ := core.SessionGet(sessionId) | |
| if s == nil { | |
| rw.WriteHeader(http.StatusNotFound) | |
| return | |
| } | |
| i := core.InstanceGet(s, instanceName) | |
| if i == nil { | |
| rw.WriteHeader(http.StatusNotFound) | |
| return | |
| } | |
| tree, err := core.InstanceFSTree(i) | |
| if err != nil { | |
| log.Println(err) | |
| rw.WriteHeader(http.StatusInternalServerError) | |
| return | |
| } | |
| rw.Header().Set("content-type", "application/json") | |
| if _, err = io.Copy(rw, tree); err != nil { | |
| log.Println(err) | |
| rw.WriteHeader(http.StatusInternalServerError) | |
| return | |
| } | |
| } | |