initial commit
This commit is contained in:
commit
85d50ee958
26 files changed
+2146
No files matched your search
@@ -0,0 +1,16 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"up/api"
|
||||
)
|
||||
|
||||
func Configure() {
|
||||
http.Handle("/", api.SpaHandler(http.FS(api.Frontend)))
|
||||
http.HandleFunc("/api/mount", api.MountStatus)
|
||||
http.HandleFunc("/api/extlinux", api.Extlinux)
|
||||
http.HandleFunc("/api/filedate", api.FileDate)
|
||||
http.HandleFunc("/api/temperature", api.HandleTemperature)
|
||||
http.HandleFunc("/api/upload", api.HandleUpload)
|
||||
http.HandleFunc("/api/reboot", api.HandleReboot)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func Run() {
|
||||
if os.Getenv("ENABLE_TLS") == "true" {
|
||||
err := http.ListenAndServeTLS(
|
||||
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
|
||||
os.Getenv("CERT_FILE"),
|
||||
os.Getenv("KEY_FILE"),
|
||||
nil,
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
err := http.ListenAndServe(
|
||||
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
|
||||
nil,
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user