Skip to content

Instantly share code, notes, and snippets.



Created Jan 20, 2020
What would you like to do?
Go Video Web NAS
// Create a video with the path: ./media/test.mkv
package main
import (
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/media/", func(w http.ResponseWriter, r *http.Request) {
h := http.StripPrefix("/media/", http.FileServer(http.Dir("./media")))
h.ServeHTTP(w, r)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("content-type", "text/html")
t := template.Must(template.New("index").Parse(`<video src="/media/test.mkv" type="video/mkv" controls style="width: 100%; height: 100%"></video>`))
t.ExecuteTemplate(w, "index", map[string]string{})
log.Fatal(http.ListenAndServe(":8000", mux))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.