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 @@ + + +
+