Added backend
This commit is contained in:
18
backend/server/path.go
Normal file
18
backend/server/path.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"TheAdversary/config"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func ServePath(w http.ResponseWriter, r *http.Request) {
|
||||
path := filepath.Join(config.FrontendDir, strings.TrimPrefix(r.URL.Path, config.SubPath))
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
Error404(w, r)
|
||||
} else {
|
||||
http.ServeFile(w, r, path)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user