feat: Added first chapter sources

This commit is contained in:
syrell 2024-10-09 23:11:23 +02:00
parent 3b16737003
commit f7d9b3ffc7
4 changed files with 32 additions and 0 deletions

BIN
assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module github.com/finchrelia/chirpy-server
go 1.22.5

7
index.html Normal file
View File

@ -0,0 +1,7 @@
<html>
<body>
<h1>Welcome to Chirpy</h1>
</body>
</html>

22
main.go Normal file
View File

@ -0,0 +1,22 @@
package main
import (
"net/http"
)
func main() {
mux := http.NewServeMux()
fileServer := http.FileServer(http.Dir("."))
mux.Handle("/app", http.StripPrefix("/app", fileServer))
mux.Handle("/app/assets/", http.StripPrefix("/app/assets/", http.FileServer(http.Dir("./assets/"))))
mux.HandleFunc("/healthz", func(w http.ResponseWriter, req *http.Request) {
req.Header.Set("Content-Type", "text/plain; charset=utf-8")
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
})
server := &http.Server{
Addr: ":8080",
Handler: mux,
}
server.ListenAndServe()
}