From dfd16ab4e262168764fe9b4044c10a6a8a2aa48e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Dvo=C5=99=C3=A1k?= <150935816+Dvorinka@users.noreply.github.com> Date: Wed, 21 May 2025 12:28:52 +0200 Subject: [PATCH] Delete folderopener directory --- folderopener/main.go | 68 ----------------------------------- folderopener/start_server.bat | 4 --- 2 files changed, 72 deletions(-) delete mode 100644 folderopener/main.go delete mode 100644 folderopener/start_server.bat diff --git a/folderopener/main.go b/folderopener/main.go deleted file mode 100644 index 39df026..0000000 --- a/folderopener/main.go +++ /dev/null @@ -1,68 +0,0 @@ -package main - -import ( - "fmt" - "log" - "net/http" - "os/exec" - "strings" -) - -func main() { - // Set up HTTP server - http.HandleFunc("/open", openFolderHandler) - - // Start server on port 8080 - fmt.Println("Folder opener server running on http://localhost:8080") - log.Fatal(http.ListenAndServe(":8080", nil)) -} - -func openFolderHandler(w http.ResponseWriter, r *http.Request) { - // Set CORS headers to allow requests from any origin - w.Header().Set("Access-Control-Allow-Origin", "*") - w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS") - w.Header().Set("Access-Control-Allow-Headers", "Content-Type") - - // Handle preflight OPTIONS request - if r.Method == "OPTIONS" { - w.WriteHeader(http.StatusOK) - return - } - - // Only allow GET requests - if r.Method != "GET" { - http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) - return - } - - // Get the folder path from the query parameter - folderPath := r.URL.Query().Get("path") - if folderPath == "" { - http.Error(w, "Missing path parameter", http.StatusBadRequest) - return - } - - // Log the request - fmt.Printf("Opening folder: %s\n", folderPath) - - // Open the folder in Windows Explorer - // The /select flag opens Explorer with the specified folder selected - cmd := exec.Command("explorer.exe", folderPath) - err := cmd.Start() - - if err != nil { - // If there was an error, try to clean the path and retry - cleanPath := strings.ReplaceAll(folderPath, "/", "\\") - cmd = exec.Command("explorer.exe", cleanPath) - err = cmd.Start() - - if err != nil { - http.Error(w, fmt.Sprintf("Error opening folder: %v", err), http.StatusInternalServerError) - return - } - } - - // Return success response - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, "Opening folder: %s", folderPath) -} diff --git a/folderopener/start_server.bat b/folderopener/start_server.bat deleted file mode 100644 index 32ac4a2..0000000 --- a/folderopener/start_server.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -echo Starting Folder Opener Server... -cd %~dp0 -go run main.go