mirror of
https://github.com/arnaucube/md-live-server.git
synced 2026-02-07 11:56:39 +01:00
add page error when file don't exists
This commit is contained in:
6
main.go
6
main.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -60,6 +61,11 @@ func getPage(w http.ResponseWriter, r *http.Request) {
|
||||
path = strings.Replace(path, "%", "/", -1)
|
||||
log.Println(path)
|
||||
|
||||
if len(strings.Split(path, ".")) < 2 {
|
||||
fmt.Fprintf(w, errTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Split(path, ".")[1] != "md" {
|
||||
http.ServeFile(w, r, path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user