summaryrefslogtreecommitdiff
path: root/server/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/main.go')
-rw-r--r--server/main.go48
1 files changed, 0 insertions, 48 deletions
diff --git a/server/main.go b/server/main.go
deleted file mode 100644
index 63aadb5..0000000
--- a/server/main.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package main
-
-import (
- "fmt"
- "net/http"
- "flag"
- "path/filepath"
- log "github.com/sirupsen/logrus"
-)
-
-
-func main() {
- log.SetFormatter(&log.TextFormatter{
- FullTimestamp: true,
- });
-
- pathFlag := flag.String(
- "path", "data", "the path to load site data from",
- );
- addrFlag := flag.String(
- "addr", "127.0.0.1:8080", "the address to serve from",
- );
- flag.Parse();
- log.Infof("data path: %v", *pathFlag);
- log.Infof("serving from %v", *addrFlag);
-
- mux := http.NewServeMux()
- mux.HandleFunc("/ip", func(w http.ResponseWriter, req *http.Request) {
- fmt.Fprintf(w, "%v", req.RemoteAddr);
- });
- mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
- if req.URL.Path != "/" {
- path := filepath.Join(*pathFlag, req.URL.Path);
- Serve(w, req, path);
- } else {
- Serve(w, req, filepath.Join(*pathFlag, "index.md"));
- }
- });
-
- server := http.Server{
- Addr: *addrFlag,
- Handler: mux,
- };
- err := server.ListenAndServe();
- if err != nil {
- log.Fatal(err);
- }
-}