Serving index.html

This commit is contained in:
2025-03-11 16:53:09 +02:00
parent dc1cbd2dc6
commit d324deef96
4 changed files with 33 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.idea
out

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module github.com/rdarius/go-http-server
go 1.23.6

21
main.go Normal file
View File

@@ -0,0 +1,21 @@
package main
import (
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.Handle("/", http.FileServer(http.Dir("./public")))
server := &http.Server{
Addr: ":8080",
Handler: mux,
}
// Start the server
if err := server.ListenAndServe(); err != nil {
panic(err)
}
}

7
public/index.html Normal file
View File

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