mirror of
https://github.com/arnaucube/goImgServer.git
synced 2026-02-07 03:26:43 +01:00
update
This commit is contained in:
@@ -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"
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
2
main.go
2
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))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"`
|
||||||
|
|||||||
Reference in New Issue
Block a user