summaryrefslogtreecommitdiff
path: root/src/web.go
diff options
context:
space:
mode:
authorxengineering <mail2xengineering@protonmail.com>2021-06-11 09:06:56 +0200
committerxengineering <mail2xengineering@protonmail.com>2021-06-11 09:12:06 +0200
commitd93959de9f7ffd061dc57bec7c532829f592bf77 (patch)
tree5b6986d280a06d5671ed8657427ab87d1873742a /src/web.go
parent5ee9c18acf25ca06dfacdb857edbd54b8454b7e8 (diff)
downloadbirdscan-d93959de9f7ffd061dc57bec7c532829f592bf77.tar
birdscan-d93959de9f7ffd061dc57bec7c532829f592bf77.tar.zst
birdscan-d93959de9f7ffd061dc57bec7c532829f592bf77.zip
Implement Web Server
Diffstat (limited to 'src/web.go')
-rw-r--r--src/web.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/web.go b/src/web.go
new file mode 100644
index 0000000..c0732ad
--- /dev/null
+++ b/src/web.go
@@ -0,0 +1,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))
+}
+