This commit is contained in:
lbenedar
2026-02-27 12:18:08 +03:00
parent de0c6088d5
commit 6876c4a55f
2 changed files with 29 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.exe

30
main.go
View File

@@ -1,7 +1,33 @@
package main
import "fmt"
import (
"log"
"net/http"
)
func home(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
w.Write([]byte("Hello from Snippetbox"))
}
func snippetView(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Display a specific snippet..."))
}
func snippetCreate(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Create a new snippet"))
}
func main() {
fmt.Println("Hello world!")
mux := http.NewServeMux()
mux.HandleFunc("/", home)
mux.HandleFunc("/snippet/view", snippetView)
mux.HandleFunc("/snippet/create", snippetCreate)
log.Print("Starting server on :4000")
err := http.ListenAndServe(":4000", mux)
log.Fatal(err)
}