trakr/server/server.go

40 lines
811 B
Go
Raw Normal View History

2023-12-22 22:05:30 +01:00
package server
import (
"fmt"
"log"
"net/http"
_ "github.com/mattn/go-sqlite3"
)
var onePixelGIF = []byte{
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00,
0x01, 0x00, 0x80, 0xff, 0x00, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44,
0x01, 0x00, 0x3b,
}
func Server() {
2023-12-22 22:23:01 +01:00
db = initDB(getenv("DATA", ".") + "/data.sqlite")
2023-12-22 22:05:30 +01:00
http.HandleFunc("/new", newPixelPageHandler)
http.HandleFunc("/create-pixel", createPixelHandler)
http.HandleFunc("/p/", pixelHandler)
http.HandleFunc("/dashboard", dashboardHandler)
2023-12-22 22:23:01 +01:00
addr := ":80"
2023-12-22 22:05:30 +01:00
2023-12-22 22:23:01 +01:00
fmt.Printf("Server is up and running on port %s\n", addr)
2023-12-22 22:05:30 +01:00
log.Fatal(http.ListenAndServe(addr, nil))
}
type PixelStats struct {
Title string
TotalViews int
UniqueViews int
UUID string
}