all repos — vite @ 589694da6b9c219b6627980ac86d1a6435d0176a

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
}