all repos — vite @ 96a6bc1beff5862b46f9a7157dd53b8a64e11fff

a fast (this time, actually) and minimal static site generator

commands/serve.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
package commands

import (
	"fmt"
	"net/http"
)

func Serve(addr string) error {
	fs := http.FileServer(http.Dir("./build"))
	mux := http.NewServeMux()
	mux.Handle("/", fs)
	fmt.Printf("vite: serving on %s\n", addr)
	if err := http.ListenAndServe(addr, mux); err != nil {
		return err
	}
	return nil
}