R
Railway13mo ago
Logan

Simple Webserver not responding

I tried making a simple webserver with Go and HTMX but it seems like it's not working, any idea what I am doing wrong here?
package main

import (
"log"
"net/http"
)

func main() {

// Serve static assets like CSS, JS, images, etc.
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "html/index.html")
})

http.HandleFunc("/content", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Content loaded with HTMX!"))
})

log.Println("Server is running")
http.ListenAndServe(":8080", nil)
}
package main

import (
"log"
"net/http"
)

func main() {

// Serve static assets like CSS, JS, images, etc.
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "html/index.html")
})

http.HandleFunc("/content", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Content loaded with HTMX!"))
})

log.Println("Server is running")
http.ListenAndServe(":8080", nil)
}
No description
5 Replies
Percy
Percy13mo ago
Project ID: afee4993-5a10-4e8d-9b94-5501e51d6fff
Logan
LoganOP13mo ago
afee4993-5a10-4e8d-9b94-5501e51d6fff
Logan
LoganOP13mo ago
Awesome thanks
Brody
Brody13mo ago
no problem!
Want results from more Discord servers?
Add your server