blob: 2baf36dc2d716c2a4aef63b3cae58deda5619c3d [file] [log] [blame]
Philipp Schrader5562df72022-02-16 20:56:51 -08001package main
2
3import (
4 "flag"
5 "fmt"
6 "os"
7 "os/signal"
8 "syscall"
9
Philipp Schradercdb5cfc2022-02-20 14:57:07 -080010 "github.com/frc971/971-Robot-Code/scouting/webserver/requests"
Philipp Schrader5562df72022-02-16 20:56:51 -080011 "github.com/frc971/971-Robot-Code/scouting/webserver/server"
12 "github.com/frc971/971-Robot-Code/scouting/webserver/static"
13)
14
15func main() {
16 portPtr := flag.Int("port", 8080, "The port number to bind to.")
17 dirPtr := flag.String("directory", ".", "The directory to serve at /.")
18 flag.Parse()
19
20 scoutingServer := server.NewScoutingServer()
21 static.ServePages(scoutingServer, *dirPtr)
Philipp Schradercdb5cfc2022-02-20 14:57:07 -080022 requests.HandleRequests(scoutingServer)
Philipp Schrader5562df72022-02-16 20:56:51 -080023 scoutingServer.Start(*portPtr)
24 fmt.Println("Serving", *dirPtr, "on port", *portPtr)
25
26 // Block until the user hits Ctrl-C.
27 sigint := make(chan os.Signal, 1)
28 signal.Notify(sigint, syscall.SIGINT)
29 fmt.Println("Waiting for CTRL-C or SIGINT.")
30 <-sigint
31
32 fmt.Println("Shutting down.")
33 scoutingServer.Stop()
34 fmt.Println("Successfully shut down.")
35}