Add files via upload

This commit is contained in:
Tomáš Dvořák
2025-05-22 10:58:28 +02:00
committed by GitHub
parent 0d9c6c1771
commit a81b5f9ffd
3 changed files with 34 additions and 20 deletions
+4 -4
View File
@@ -95,7 +95,7 @@ monitor: ## Monitor the service with file watching
@while true; do \
inotifywait -e modify contacts.xlsx 2>/dev/null && \
echo "File changed, reloading..." && \
curl -X POST http://localhost:$(PORT)/reload; \
curl -X POST http://localhost:$(PORT)/kontakt/reload; \
sleep 1; \
done
@@ -136,6 +136,6 @@ info: ## Show application information
@echo "Build dir: $(BUILD_DIR)"
@echo ""
@echo "Endpoints:"
@echo " http://localhost:$(PORT)/ - Web interface"
@echo " http://localhost:$(PORT)/contacts - JSON API"
@echo " http://localhost:$(PORT)/reload - Reload data (POST)"
@echo " http://localhost:$(PORT)/kontakt - Web interface"
@echo " http://localhost:$(PORT)/kontakt/contacts - JSON API"
@echo " http://localhost:$(PORT)/kontakt/reload - Reload data (POST)"
+20
View File
@@ -35,12 +35,32 @@ var (
xlsxFile = "contacts.xlsx"
)
func startAutoReload() {
ticker := time.NewTicker(3 * 24 * time.Hour)
quit := make(chan struct{})
go func() {
for {
select {
case <-ticker.C:
log.Println("Auto-reloading contact data...")
loadData()
case <-quit:
ticker.Stop()
return
}
}
}()
}
func main() {
// Create data directory if it doesn't exist
if err := os.MkdirAll("data", 0755); err != nil {
log.Printf("Warning: Could not create data directory: %v", err)
}
// Start auto-reload scheduler
startAutoReload()
// Load existing data or parse from Excel
loadData()