This commit is contained in:
Pavel Flegr 2026-05-07 18:22:07 +02:00
commit 1f6a3a03d8
2 changed files with 19 additions and 2 deletions

21
main.go
View file

@ -4,8 +4,10 @@ import (
"encoding/json"
"log"
"net/http"
"os"
"prsi/internal/api"
"prsi/internal/llm"
"strings"
)
func main() {
@ -56,8 +58,23 @@ func main() {
json.NewEncoder(w).Encode(result)
})
log.Println("Server starting on :8080")
if err := http.ListenAndServe(":8080", nil); err != nil {
addr := serverAddr()
log.Printf("Server starting on %s", addr)
if err := http.ListenAndServe(addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
func serverAddr() string {
port := strings.TrimSpace(os.Getenv("PORT"))
if port == "" {
port = strings.TrimSpace(os.Getenv("APP_PORT"))
}
if port == "" {
port = "8080"
}
if strings.HasPrefix(port, ":") {
return port
}
return ":" + port
}

BIN
prsi

Binary file not shown.