Browse Source

update

master
arnaucode 7 years ago
parent
commit
19d53b1d5b
4 changed files with 7 additions and 5 deletions
  1. +2
    -2
      config.json
  2. +2
    -2
      handlers.go
  3. +1
    -1
      main.go
  4. +2
    -0
      readConfig.go

+ 2
- 2
config.json

@ -1,8 +1,8 @@
{ {
"serverIP": "127.0.0.1",
"serverPort": "3050",
"folder": "files", "folder": "files",
"blockedIPs": [ "blockedIPs": [
"192.168.1.3",
"147.116.48.158"
], ],
"allowedIPs": [ "allowedIPs": [
"127.0.0.1" "127.0.0.1"

+ 2
- 2
handlers.go

@ -18,7 +18,7 @@ func ImageShow(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
imageName := vars["imageName"] imageName := vars["imageName"]
file, err := ioutil.ReadFile(imageName)
file, err := ioutil.ReadFile(config.Folder + "/" + imageName)
if err != nil { if err != nil {
fmt.Fprintln(w, err) fmt.Fprintln(w, err)
} }
@ -63,5 +63,5 @@ func NewImage(w http.ResponseWriter, r *http.Request) {
fmt.Println(err) fmt.Println(err)
} }
fmt.Fprintln(w, "url:", fileName)
fmt.Fprintln(w, config.ServerIP+":"+config.ServerPort+"/images/"+fileName)
} }

+ 1
- 1
main.go

@ -12,5 +12,5 @@ func main() {
router := NewRouter() router := NewRouter()
log.Fatal(http.ListenAndServe(":3050", router))
log.Fatal(http.ListenAndServe(":"+config.ServerPort, router))
} }

+ 2
- 0
readConfig.go

@ -7,6 +7,8 @@ import (
) )
type Config struct { type Config struct {
ServerIP string `json:"serverIP"`
ServerPort string `json:"serverPort"`
Folder string `json:"foldIPs` Folder string `json:"foldIPs`
BlockedIPs []string `json:"blockedIPs"` BlockedIPs []string `json:"blockedIPs"`
AllowedIPs []string `json:"allowedIPs"` AllowedIPs []string `json:"allowedIPs"`

Loading…
Cancel
Save