29 lines
669 B
Go
29 lines
669 B
Go
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)
|
|
}
|
|
} |