simple-http-server
"/home/yossef/notes/full-stack/go-net-http/simple-http-server.md"
path: full-stack/go-net-http/simple-http-server.md
- **fileName**: simple-http-server
- **Created on**: 2025-02-17 23:42:37
first must have a the basic fundamentals for golang
for more information about go lang check this
../../tags/courses-tags#go
starting with making a simple http server
package main
import ( //staring import main packages
"fmt"
"net/http"
)
func main() {
// HandleFunc it's a function for handle http request
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request){
fmt.Fprintf(w, "welcome")
})
http.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request){
fmt.Fprintf(w, "welcome from users page")
})
// starting linsten and serve the server
if err := http.ListenAndServe(":4444", nil); err != nil {
fmt.Println("error happend in server: ", err)
}
}
continue:[[]]
before:[[]]