majianyu
1/26/2018 - 8:17 AM

file_server

静态文件服务

package main

import (
    "net/http"
)

func main() {
    files := http.FileServer(http.Dir("./public/"))
    // 过滤 URL 中/static/
    http.Handle("/static/",http.StripPrefix("/static/",files))
    http.ListenAndServe("localhost:8000",nil)
    
}