Add main.go

This commit is contained in:
2025-10-08 00:54:42 +02:00
commit b233172108

29
main.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import (
"log"
"net/http"
"os/exec"
)
func handler(w http.ResponseWriter, r *http.Request) {
cmd := exec.Command("fastfetch")
out, err := cmd.CombinedOutput()
if err != nil {
http.Error(w, "Error running fastfetch: "+err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "text/plain")
w.Write(out)
}
func main() {
http.HandleFunc("/", handler)
log.Println("Server listening on :8080")
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal(err)
}
}