package api

import (
	"fmt"
	"net/http"
	"time"
)

func homePage(w http.ResponseWriter, r *http.Request) {
	page := "." + r.URL.Path
	t := time.Now()
	formattedTime := fmt.Sprintf("%d/%d/%d %d:%d:%d",
		t.Month(), t.Day(), t.Year(),
		t.Hour(), t.Minute(), t.Second())
	switch page {
	case "./":
		page = "./api/html/index.html"
		break
	default:
		fmt.Println("[" + formattedTime + "] " + r.RemoteAddr + " => " + page)
		page = "./api/html/404.html"
		break
	}
	http.ServeFile(w, r, page)
}
