From d324deef9638d9d886e453b666752a277a89f0b6 Mon Sep 17 00:00:00 2001 From: Darius Rapalis Date: Tue, 11 Mar 2025 16:53:09 +0200 Subject: [PATCH] Serving index.html --- .gitignore | 2 ++ go.mod | 3 +++ main.go | 21 +++++++++++++++++++++ public/index.html | 7 +++++++ 4 files changed, 33 insertions(+) create mode 100644 .gitignore create mode 100644 go.mod create mode 100644 main.go create mode 100644 public/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fca352e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +out \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..2e5598d --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/rdarius/go-http-server + +go 1.23.6 diff --git a/main.go b/main.go new file mode 100644 index 0000000..4cc349f --- /dev/null +++ b/main.go @@ -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) + } +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..e561347 --- /dev/null +++ b/public/index.html @@ -0,0 +1,7 @@ + + + +

Welcome to Chirpy

+ + + \ No newline at end of file