improve logging

This commit is contained in:
2025-08-02 17:06:19 -07:00
parent 9404a91f51
commit 90f03afc3d

View File

@@ -8,8 +8,8 @@ import (
"net/http" "net/http"
"strconv" "strconv"
_ "modernc.org/sqlite"
"github.com/google/uuid" "github.com/google/uuid"
_ "modernc.org/sqlite"
) )
var ( var (
@@ -17,7 +17,7 @@ var (
) )
func main() { func main() {
fmt.Println("hello, world!") fmt.Println("ugh. can i go back to eep?")
var err error var err error
db, err = sql.Open("sqlite", "./db/notes.db") db, err = sql.Open("sqlite", "./db/notes.db")
if err != nil { if err != nil {
@@ -45,7 +45,7 @@ func main() {
} }
w.Header().Add("Content-Type", "text/json") w.Header().Add("Content-Type", "text/json")
fmt.Fprint(w, string(jsonString)) fmt.Fprint(w, string(jsonString))
fmt.Println(string(jsonString)) // fmt.Println(string(jsonString))
}) })
http.HandleFunc("/new", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/new", func(w http.ResponseWriter, r *http.Request) {
@@ -60,7 +60,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
newNote(r.Form.Get("user"), r.Form.Get("data"), uuid.String()) newNote(r.Form.Get("user"), r.Form.Get("data"), uuid.String())
fmt.Fprint(w, uuid) fmt.Fprint(w, uuid)
}) })
@@ -90,6 +90,7 @@ func main() {
fmt.Fprint(w, http.StatusText(200)) fmt.Fprint(w, http.StatusText(200))
}) })
fmt.Println("listening on :3000")
log.Fatal(http.ListenAndServe(":3000", nil)) log.Fatal(http.ListenAndServe(":3000", nil))
} }