backend: WIP

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2023-09-15 06:39:05 -04:00
parent d5c43d0624
commit c811d35fa5
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED
5 changed files with 77 additions and 0 deletions

View file

@ -1,3 +1,10 @@
module git.batts.cloud/vbatts/critter/backend module git.batts.cloud/vbatts/critter/backend
go 1.20 go 1.20
require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/redis/go-redis/v9 v9.1.0 // indirect
)

8
backend/go.sum Normal file
View file

@ -0,0 +1,8 @@
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/redis/go-redis/v9 v9.1.0 h1:137FnGdk+EQdCbye1FW+qOEcY5S+SpY9T0NiuqvtfMY=
github.com/redis/go-redis/v9 v9.1.0/go.mod h1:urWj3He21Dj5k4TK1y59xH8Uj6ATueP8AH1cY3lZl4c=

30
backend/main.go Normal file
View file

@ -0,0 +1,30 @@
package main
import (
"net/http"
"text/template"
"github.com/gorilla/mux"
"github.com/redis/go-redis/v9"
)
var (
client *redis.Client
templates *template.Template
)
func main() {
client = redis.NewClient(&redis.Options{
Addr: "localhost:6379",
DB: 0,
})
templates = template.Must(template.ParseGlob("templates/*.html"))
r := mux.NewRouter()
r.HandleFunc("/", indexHandler).Methods("GET")
http.Handle("/", r)
http.ListenAndServe(":8080", nil)
}
func indexHandler(w http.ResponseWriter, r *http.Request) {
templates.ExecuteTemplate(w, "index.html", nil)
}

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,31 @@
<html>
<head>
<script src="https://cdn.jsdelivr.net/gh/TA3/web-user-behaviour/userBehaviour.min.js"></script>
<script src="https://unpkg.com/htmx.org@1.9.5" integrity="sha384-xcuj3WpfgjlKF+FXhSQFQ0ZNr39ln+hwjN3npfM9VBnUskLolQAcN80McRIVOPuO" crossorigin="anonymous"></script>
<script>
userBehaviour.config( {
userInfo: true,
clicks: true,
mouseMovement: true,
mouseMovementInterval: 1,
mouseScroll: true,
timeCount: true,
clearAfterProcess: true,
processTime: 15,
processData: function(results){
console.log(results);
},
});
userBehaviour.start();
</script>
</head>
<body>
booger snatch
<button hx-post="/clicked" hx-trigger="click" hx-target="#parent-div" hx-swap="outerHTML" >is critter</button>
<button hx-post="/clicked" hx-trigger="click" hx-target="#parent-div" hx-swap="outerHTML" >is not critter</button>
</body>
</html>