Update web handling
This commit is contained in:
parent
00aa052a61
commit
bfc14ce717
BIN
static/favicon.ico
Normal file
BIN
static/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
static/favicon.png
Normal file
BIN
static/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta name="charset" content="utf-8" />
|
||||
<title>barcodes</title>
|
||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||
<!-- CSS and JS Inclusions -->
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
14
web/page.route.go
Normal file
14
web/page.route.go
Normal file
@ -0,0 +1,14 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func mainHandler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Println("Request URL: ", r.URL.Path)
|
||||
requestFile := strings.TrimRight(r.URL.Path, "/")
|
||||
requestFile = strings.TrimRight(requestFile, ".html")
|
||||
fmt.Println("Template File: ", requestFile)
|
||||
}
|
@ -6,9 +6,10 @@ import (
|
||||
)
|
||||
|
||||
func StartServer() {
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "Barcodes")
|
||||
})
|
||||
// What I want to do here is server from /static
|
||||
// if the resource exists, else try to render from /templates
|
||||
// if the template exists. Else return 404.
|
||||
http.HandleFunc("/", mainHandler)
|
||||
|
||||
http.HandleFunc("/help", helpTemplate)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user