mirror of
https://github.com/Lomanic/presence-button-web
synced 2024-11-24 14:37:29 +00:00
WIP
This commit is contained in:
parent
16dc72f1bf
commit
09d882dc10
29
main.go
29
main.go
@ -4,8 +4,37 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
db = "./.data/data.json"
|
||||||
|
defaultClosingTimeout = 5 * time.Minute
|
||||||
|
// epochTime = time.Date(1970, time.January, 01, 0, 0, 0, 0, time.UTC)
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
fuzIsOpen = false
|
||||||
|
epochTime = time.Date(1970, time.January, 01, 0, 0, 0, 0, time.UTC)
|
||||||
|
lastSeen = epochTime
|
||||||
|
lastOpened = epochTime
|
||||||
|
lastClosed = epochTime
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
err := os.MkdirAll(filepath.Dir(db), 0755)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
content, err := ioutil.ReadFile(db)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func handler(w http.ResponseWriter, r *http.Request) {
|
func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
|
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user