Create and open DB

This commit is contained in:
2024-08-16 00:27:35 -06:00
commit 33f732639f
6 changed files with 260 additions and 0 deletions

37
webadmin/main.go Normal file
View File

@ -0,0 +1,37 @@
package main
import (
"fmt"
"log"
"net"
"net/http"
"github.com/pkg/browser"
)
func handleHome(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "<h1>Hello Peachy!</h1>")
}
func run() error {
listener, err := net.Listen("tcp", ":0")
if err != nil {
return err
}
port := listener.Addr().(*net.TCPAddr).Port
homeURL := fmt.Sprintf("http://localhost:%d", port)
err = browser.OpenURL(homeURL)
if err != nil {
fmt.Printf("I couldn't open the browser automatically.\nDo it yourself, then go to %s.", homeURL)
}
return http.Serve(listener, http.HandlerFunc(handleHome))
}
func main() {
err := run()
if err != nil {
log.Fatal(err)
}
}