mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-03 20:12:59 +00:00
Add files via upload
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
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))
|
||||
@@ -22,46 +22,46 @@ func openFolderHandler(w http.ResponseWriter, r *http.Request) {
|
||||
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)
|
||||
|
||||
+3
-3
@@ -72,7 +72,7 @@
|
||||
</div>
|
||||
<h2 class="text-xl font-bold text-gray-800 mb-2">OSTicket</h2>
|
||||
<p class="text-gray-600 mb-4">Systém technické podpory a hlášení problémů</p>
|
||||
<a href="http://osticket/" class="block text-center bg-orange-600 hover:bg-orange-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
|
||||
<a href="#" class="block text-center bg-orange-600 hover:bg-orange-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
|
||||
Otevřít aplikaci
|
||||
</a>
|
||||
</div>
|
||||
@@ -82,9 +82,9 @@
|
||||
<div class="rounded-full w-14 h-14 flex items-center justify-center bg-purple-100 text-purple-600 mb-4">
|
||||
<i class="fas fa-tasks text-2xl"></i>
|
||||
</div>
|
||||
<h2 class="text-xl font-bold text-gray-800 mb-2">Kanboard</h2>
|
||||
<h2 class="text-xl font-bold text-gray-800 mb-2">Canboard úkolníček</h2>
|
||||
<p class="text-gray-600 mb-4">Správa úkolů a projektů v přehledném kanban stylu</p>
|
||||
<a href="http://kanboard/" class="block text-center bg-purple-600 hover:bg-purple-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
|
||||
<a href="#" class="block text-center bg-purple-600 hover:bg-purple-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
|
||||
Otevřít aplikaci
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -168,32 +168,18 @@ func openFolderHandler(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "Missing path parameter", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Log the request
|
||||
log.Printf("Otevírání složky: %s", folderPath)
|
||||
|
||||
// Properly handle backslashes in Windows paths
|
||||
// First, replace any forward slashes with backslashes
|
||||
folderPath = strings.ReplaceAll(folderPath, "/", "\\")
|
||||
|
||||
// Fix any double backslashes that might have been created by JavaScript escaping
|
||||
for strings.Contains(folderPath, "\\\\") {
|
||||
folderPath = strings.ReplaceAll(folderPath, "\\\\", "\\")
|
||||
}
|
||||
|
||||
// Log the cleaned path
|
||||
log.Printf("Upravená cesta: %s", folderPath)
|
||||
|
||||
// Open the folder in Windows Explorer
|
||||
cmd := exec.Command("explorer.exe", folderPath)
|
||||
err := cmd.Start()
|
||||
|
||||
if err != nil {
|
||||
// If there was an error, try opening the parent directory
|
||||
log.Printf("Chyba při otevírání složky: %v, zkouším jinou metodu", err)
|
||||
|
||||
// Try using /root,path format which sometimes works better
|
||||
cmd = exec.Command("explorer.exe", "/root," + folderPath)
|
||||
// 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 {
|
||||
@@ -202,7 +188,7 @@ func openFolderHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return success response
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user