summaryrefslogtreecommitdiff
path: root/src/web.go
blob: c0732ad6a417dbe83e11590c944b31e76b47ed87 (plain)
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
// vim: shiftwidth=4 tabstop=4 noexpandtab

package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/go-chi/chi/v5"
	"github.com/go-chi/chi/v5/middleware"
)

const (
	APP_DATA = "/usr/share/birdscan"
)

func runServer() {
	router := chi.NewRouter()
	router.Use(middleware.Logger)

	router.Get("/", indexHandler)

	log.Println("Binding to 'http://" + "127.0.0.1" + ":" + "8080" + "'")
	log.Fatal(http.ListenAndServe("127.0.0.1" + ":" + "8080", router))
}

func indexHandler(w http.ResponseWriter, r *http.Request) {
	http.ServeFile(w, r, fmt.Sprintf("%s/html/index.html", APP_DATA))
}