package main import ( "log" "net/http" "os" "inou/lib" ) var ( Version = "dev" BuildTime = "" keyPath = "/tank/inou/master.key" dbPath = "/tank/inou/data/inou.db" authDBPath = "/tank/inou/data/auth.db" ) func main() { port := "8082" if len(os.Args) > 1 { port = os.Args[1] } if err := lib.CryptoInit(keyPath); err != nil { log.Fatalf("Failed to init crypto: %v", err) } if err := lib.DBInit(dbPath + "?_journal_mode=WAL&_busy_timeout=5000"); err != nil { log.Fatalf("Failed to init lib database: %v", err) } defer lib.DBClose() if err := lib.AuthDBInit(authDBPath + "?_journal_mode=WAL&_busy_timeout=5000"); err != nil { log.Fatalf("Failed to init auth database: %v", err) } defer lib.AuthDBClose() http.HandleFunc("/api/version", handleVersion) http.HandleFunc("/api/dossiers", handleDossiers) http.HandleFunc("/api/dossier", handleDossier) http.HandleFunc("/api/studies", handleStudies) http.HandleFunc("/api/genome", handleGenomeQuery) http.HandleFunc("/api/categories", handleCategories) http.HandleFunc("/api/series", handleSeries) http.HandleFunc("/api/slices", handleSlices) http.HandleFunc("/image/", handleImage) http.HandleFunc("/contact-sheet.webp/", handleContactSheet) http.HandleFunc("/api/labs/tests", handleLabTests) http.HandleFunc("/api/labs/results", handleLabResults) http.HandleFunc("/api/access", handleAccess) http.HandleFunc("/api/audit", handleAudit) http.HandleFunc("/api/entries", handleEntries) http.HandleFunc("/api/prompts", handlePromptsRouter) http.HandleFunc("/api/prompts/", handlePromptsRouter) // http.HandleFunc("/api/prompt/generate", handlePromptGenerate) // REMOVED: Deprecated // Add the missing freeform handler http.HandleFunc("/api/prompts/freeform", handleFreeform) // V1 API (new design) RegisterV1Routes() loadLLMConfig() // RENAMED from loadAnthropicConfig() // Load translations for CategoryTranslate lib.TranslateInit("/tank/inou/portal/lang") log.Printf("API server %s starting on :%s", Version, port) log.Fatal(http.ListenAndServe(":"+port, nil)) }