mirror of
https://github.com/alice-lg/alice-lg.git
synced 2024-05-11 05:55:03 +00:00
added static file handling
This commit is contained in:
7
backend/.gitignore
vendored
Normal file
7
backend/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
# Ignore static build in repo
|
||||
rice-box.go
|
||||
|
||||
# Ignore builds
|
||||
alice-lg-*
|
||||
|
@@ -1,7 +1,32 @@
|
||||
package main
|
||||
|
||||
import ()
|
||||
import (
|
||||
"github.com/GeertJohan/go.rice"
|
||||
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
printBanner()
|
||||
|
||||
// Load configuration
|
||||
|
||||
// Serve static assets
|
||||
assets := rice.MustFindBox("../client/build")
|
||||
assetsHandler := http.StripPrefix(
|
||||
"/static/",
|
||||
http.FileServer(assets.HTTPBox()))
|
||||
|
||||
index, err := assets.String("index.html")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Println(index)
|
||||
|
||||
http.Handle("/static/", assetsHandler)
|
||||
|
||||
// Start http server
|
||||
http.ListenAndServe(":7340", nil)
|
||||
}
|
||||
|
Reference in New Issue
Block a user