Server now has ability to serve static files.
This commit is contained in:
parent
31b81a10d7
commit
c934ac6753
19
main.go
Normal file
19
main.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
var addr = flag.String("addr", ":8000", "http service address")
|
||||||
|
var static_files = flag.String("static", "./static", "static files")
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
http.Handle("/s/", http.StripPrefix("/s/",
|
||||||
|
http.FileServer(http.Dir(*static_files))))
|
||||||
|
if err := http.ListenAndServe(*addr, nil); err != nil {
|
||||||
|
log.Fatal("ListenAndServe:", err)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user