Mercurial > mercurial > hgweb_golang.cgi
diff src/kaigo/horori/searcher/server/searcher.go @ 49:8384ca56f1b4
small changes.
author | pyon@macmini |
---|---|
date | Thu, 23 Apr 2020 22:54:58 +0900 |
parents | ca00c4a85b98 |
children | 4e14902379da |
line wrap: on
line diff
--- a/src/kaigo/horori/searcher/server/searcher.go Wed Apr 22 19:00:50 2020 +0900 +++ b/src/kaigo/horori/searcher/server/searcher.go Thu Apr 23 22:54:58 2020 +0900 @@ -1,5 +1,5 @@ /* - Last Change: 2020-04-22 水 17:23:42. + Last Change: 2020-04-23 木 14:43:54. */ package main @@ -51,6 +51,7 @@ port string hhsdb string indexdb string + pwdb string server_root string hhash map[string]hhs iymdhash map[string]string @@ -61,12 +62,14 @@ port = ":3910" hhsdb = "hhsdb.csv" indexdb = "index.csv" + pwdb = "passwd" } func main() { server_root = filepath.Dir(os.Args[0]) hhsdb = filepath.Join(server_root, hhsdb) indexdb = filepath.Join(server_root, indexdb) + pwdb = filepath.Join(server_root, pwdb) // setting IP-Address & Port addrs, err := net.InterfaceAddrs() @@ -101,6 +104,7 @@ http.HandleFunc("/u/", uphhsdb_handler) // POST /u/ http.HandleFunc("/ui/", upimage_handler) // POST /ui/20200401/0800012345.tgz http.HandleFunc("/ci/", climage_handler) // Get /ci/20200402 + http.HandleFunc("/pw/", pw_handler) // Get /pw/ -> id1:pw1:id2:pw2:... log.Fatal(http.ListenAndServe(server, nil)) } @@ -402,3 +406,13 @@ os.RemoveAll(dir) } +/* Get /pw/ -> id1:pw1:id2:pw2:... */ +func pw_handler(w http.ResponseWriter, r *http.Request) { + b, err := ioutil.ReadFile(pwdb) + if err != nil { + http.NotFound(w, r) + return + } + w.Write([]byte(strings.ReplaceAll(string(b), "\n", ":"))) +} +