-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (30 loc) · 929 Bytes
/
main.go
File metadata and controls
39 lines (30 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"fmt"
agility "kevin-portfolio/internal/agility_cms"
"kevin-portfolio/internal/handlers"
"kevin-portfolio/views"
"log"
"net/http"
"github.com/joho/godotenv"
)
func init() {
// Load .env file into environment variables
if err := godotenv.Load(); err != nil {
log.Println("No .env file found, relying on system env")
}
// Set the sitemap
agility.RefreshSitemap()
}
func main() {
// Serve static files
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("assets/"))))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// get the home page content from CMS
homeContent := agility.GetHomeCommandContent()
views.Index(homeContent).Render(r.Context(), w)
})
http.HandleFunc("POST /terminal/command", handlers.ExecuteCommandHandler)
fmt.Println("Listening on http://localhost:8080")
http.ListenAndServe(":8080", nil)
}