-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
55 lines (49 loc) · 1.42 KB
/
main.go
File metadata and controls
55 lines (49 loc) · 1.42 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// flood is a little server that displays the latest information about
// 124th during flood season. Updates are read from the KC road alert
// RSS feed.
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
"jdtw.dev/flood/internal/server"
)
func main() {
var port = flag.Int("port", 8080, "Port to listen on")
flag.Parse()
var override server.Override
switch os.Getenv("OVERRIDE") {
case "open":
override = server.Open
case "closed":
override = server.Closed
}
apiKey := os.Getenv("GEMINI_API_KEY")
model := os.Getenv("GEMINI_MODEL")
if apiKey == "" || model == "" {
apiKey = ""
model = ""
log.Print("GEMINI_API_KEY and GEMINI_MODEL not set; AI analysis will be disabled")
} else {
log.Printf("Active Gemini model: %s", model)
}
handler, err := server.NewHandler(&server.Options{
Override: override,
FeedURL: "https://gismaps.kingcounty.gov/roadalert/rss.aspx",
Road: "124th",
Timezone: "America/Los_Angeles",
GeminiAPIKey: apiKey,
GeminiModel: model,
CameraURLs: []string{
"https://info.kingcounty.gov/transportation/kcdot/Roads/TrafficCameras/ImageHandler/Handler.ashx?id=CarDuv_SR203_124.jpg",
"https://info.kingcounty.gov/transportation/kcdot/Roads/TrafficCameras/ImageHandler/Handler.ashx?id=WSnoNE_124.jpg",
},
})
if err != nil {
log.Fatal(err)
}
log.Printf("Listening on port %d", *port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), handler))
}