Skip to content

Commit

Permalink
修正改端口bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobLai committed Aug 13, 2016
1 parent 5c70afc commit 08cbd59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 6 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"Coolpy/Deller"
"Coolpy/CoSystem"
"io/ioutil"
"strings"
"path/filepath"
)

Expand Down Expand Up @@ -130,18 +129,12 @@ func main() {
if err != nil {
log.Fatal(err)
}
if port != 6543 {
//当api端口号被启动参数修改时即自动更新www相关连接参数
settingpath := dir + "\\www\\scripts-app\\setting.js"
f, err := ioutil.ReadFile(settingpath)
if err != nil {
fmt.Println(err)
}
nstring := strings.Replace(string(f), "6543", strconv.Itoa(port), -1)
err = ioutil.WriteFile(settingpath, []byte(nstring), 0644)
if err != nil{
fmt.Println(err)
}
//当api端口号被启动参数修改时即自动更新www相关连接参数
settingpath := dir + "\\www\\scripts-app\\setting.js"
nstring := "var basicurl=\"http://\"+ window.location.hostname +\":" +strconv.Itoa(port)+ "\""
err = ioutil.WriteFile(settingpath, []byte(nstring), 0644)
if err != nil{
fmt.Println(err)
}
http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir(dir + "\\www"))))
go func() {
Expand Down
2 changes: 1 addition & 1 deletion www/scripts-app/setting.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
var basicurl = "http://"+ window.location.hostname +":6543"
var basicurl="http://"+ window.location.hostname +":6543"

0 comments on commit 08cbd59

Please sign in to comment.