updated app build

This commit is contained in:
ghostersk
2025-03-02 17:14:05 +00:00
parent bd1c372435
commit af3ffb5d6d
36 changed files with 901 additions and 2384 deletions

View File

@@ -0,0 +1,39 @@
package server
import (
"fmt"
"net/http"
"os"
"path/filepath"
)
// StartServer launches a web server on 127.0.0.1:61147
func StartServer() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
indexPath := filepath.Join("www", "index.html")
if _, err := os.Stat(indexPath); os.IsNotExist(err) {
// Create index.html if it doesnt exist
if err := os.MkdirAll("www", 0755); err != nil {
http.Error(w, "Error creating www directory", http.StatusInternalServerError)
return
}
file, err := os.Create(indexPath)
if err != nil {
http.Error(w, "Error creating index.html", http.StatusInternalServerError)
return
}
defer file.Close()
_, err = file.WriteString("<h1>GoLangProxy is up</h1>")
if err != nil {
http.Error(w, "Error writing index.html", http.StatusInternalServerError)
return
}
}
http.ServeFile(w, r, indexPath)
})
fmt.Println("Starting simple web server on 127.0.0.1:61147")
if err := http.ListenAndServe("127.0.0.1:61147", nil); err != nil {
fmt.Println("Web server error:", err)
}
}