From b692a58ee2a316ae1f2ae9814fc3ba7ebc436d49 Mon Sep 17 00:00:00 2001 From: igor Date: Thu, 22 Jan 2026 20:58:07 +0100 Subject: [PATCH] added static load files, added TPsoft logo to header, added build batch script for windows --- build.bat | 40 ++++++++++++++++++++++++++++++++++++++++ dbPrompt.go | 9 ++++++++- index.html | 27 +++++++++++++++++++-------- static/tpsoft-logo.png | Bin 0 -> 10025 bytes 4 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 build.bat create mode 100644 static/tpsoft-logo.png diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..3148580 --- /dev/null +++ b/build.bat @@ -0,0 +1,40 @@ +@echo off +setlocal + +echo ============================== +echo Building Go binaries... +echo ============================== + +set APP_NAME=dbPrompt + +REM Create output folder +if not exist dist mkdir dist + +REM Windows build +echo Building Windows... +set GOOS=windows +set GOARCH=amd64 +go build -o dist\%APP_NAME%-windows-amd64.exe + +if errorlevel 1 goto error + +REM Linux build +echo Building Linux... +set GOOS=linux +set GOARCH=amd64 +go build -o dist\%APP_NAME%-linux-amd64 + +if errorlevel 1 goto error + +echo ============================== +echo Build completed successfully! +echo Output in dist\ +goto end + +:error +echo. +echo BUILD FAILED! +exit /b 1 + +:end +endlocal diff --git a/dbPrompt.go b/dbPrompt.go index 6378574..ae8dc13 100644 --- a/dbPrompt.go +++ b/dbPrompt.go @@ -2,6 +2,7 @@ package main import ( "database/sql" + "embed" "encoding/json" "fmt" "io/ioutil" @@ -17,6 +18,9 @@ import ( _ "github.com/go-sql-driver/mysql" ) +//go:embed index.html static/* +var embeddedFiles embed.FS + // Config struct for database connection type Config struct { Username string `json:"username"` @@ -81,8 +85,11 @@ func main() { os.Mkdir(historyDir, 0755) } + // Serve static files + fs := http.FS(embeddedFiles) + // HTTP Handlers - http.HandleFunc("/", serveIndex) + http.Handle("/", http.FileServer(fs)) http.HandleFunc("/query", handleQuery) http.HandleFunc("/history/", handleHistory) diff --git a/index.html b/index.html index 46d1de1..2b8d771 100644 --- a/index.html +++ b/index.html @@ -6,10 +6,19 @@ dbPrompt