add spiegel web crawler; rename project
This commit is contained in:
41
cmd/frontend/main.go
Normal file
41
cmd/frontend/main.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user