add spiegel web crawler; rename project

This commit is contained in:
2024-12-29 00:56:47 +01:00
parent cb0e69489c
commit b47b6d51b2
5 changed files with 255 additions and 7 deletions

41
cmd/frontend/main.go Normal file
View File

@@ -0,0 +1,41 @@
package main
import (
"fmt"
"net/http"
"crowsnest/internal/model"
"crowsnest/internal/data"
)
func test(w http.ResponseWriter, req *http.Request) {
for name, headers := range req.Header {
for _, h := range headers {
fmt.Fprintf(w, "%v: %v\n", name, h)
}
}
}
func PrintAllKeys(ds data.IDatastore) {
m, err := ds.GetAllKeys()
fmt.Println(m, err)
}
func main() {
http.HandleFunc("/test", test)
// Serve files from the "static" directory
fs := http.FileServer(http.Dir("./static"))
http.Handle("/", http.StripPrefix("/", fs))
//a := &model.Article{}
fds, _ := data.NewFileDatastore("data.json")
fmt.Println(fds.GetAll())
repo, _ := data.NewDefaultRepository[*model.Article](fds, "article")
articles, _ := repo.GetAll()
fmt.Println(articles[0])
//http.ListenAndServe(":8090", nil)
}