package main

import (
	"fmt"
	"io"
	"net/http"
	"tmp/internal/database"

	_ "github.com/mattn/go-sqlite3"
)

// This is what a handler looks like
func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Println("Request received")
	io.WriteString(w, "This is my website!\n")
}

func main() {
	database.DbConnect()

	// Mounting the handler
	fs := http.FileServer(http.Dir("static"))
	http.Handle("/", fs)
	http.HandleFunc("/hello", handler)

	// Start the server on port 8080
	println("Currently listening on http://localhost:8080")
	println("Visit http://localhost:8080/hello to see the handler in action")
	println("Press Ctrl+C to stop the server")
	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		panic(err)
	}
}