logo

Lucas Katayama/Simple HTTP File Server

Created Sat, 21 Dec 2019 10:01:22 -0300 Modified Tue, 17 Dec 2019 10:01:22 -0300
45 Words

This is the simplest way to create a local server to serve local files

package main

import (
    "log"
    "net/http"
)

func main() {

    fs := http.FileServer(http.Dir("."))
    http.Handle("/", http.StripPrefix("/", fs))

    log.Fatal(http.ListenAndServeTLS(":5000", nil))
}

Just run it:

$ go run main.go

And access through browser: http://localhost:5000