Skip to content

Commit

Permalink
fix built-in index.html provider
Browse files Browse the repository at this point in the history
  • Loading branch information
tassa-yoniso-manasi-karoto committed Sep 7, 2024
1 parent 54ec9be commit ca8524b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ Download the [lastest release](https://github.com/tassa-yoniso-manasi-karoto/pal
1. Run binary from CLI
2. Open http://localhost:8080/ in your browser

Rare thai vowels are not currently supported by the library (ฤ ฤๅ ฦ ฦๅ)

<hr>

ดาวน์โหลดรุ่นล่าสุดได้[ที่นี่](https://github.com/tassa-yoniso-manasi-karoto/pali-transliteration-webui/releases)

1. รันไฟล์ไบนารีจาก CLI
2. เปิด http://localhost:8080/ ในเบราว์เซอร์ของคุณ

สระไทยที่พบได้น้อยยังไม่รองรับในไลบรารีนี้ในขณะนี้ (ฤ ฤๅ ฦ ฦๅ)
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,16 @@ func processTextHandler(w http.ResponseWriter, r *http.Request) {
}

func indexHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
var tmpl *template.Template
exeDir, err := os.Executable()
if err != nil {
tmpl, err = template.ParseFiles(index)
log.Error().Err(err).Msg("Error getting executable path")
}
templatePath := filepath.Join(filepath.Dir(exeDir), "index.html")
tmpl := template.New("index")
if _, err := os.Stat(templatePath); os.IsNotExist(err) {
log.Info().Msg("Serving built-in index.html")
tmpl, err = tmpl.Parse(index)
} else {
templatePath := filepath.Join(filepath.Dir(exeDir), "index.html")
log.Info().Msgf("Serving index.html from: %s", templatePath)
tmpl, err = template.ParseFiles(templatePath)
}
Expand Down

0 comments on commit ca8524b

Please sign in to comment.