第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

卷曲 http 服務(wù)器沒問題,但瀏覽器不起作用

卷曲 http 服務(wù)器沒問題,但瀏覽器不起作用

Go
湖上湖 2023-06-01 18:14:13
我只是在 Golang 中接近 webapps。這是作為起點(diǎn)的簡單代碼:package mainimport (        "fmt"        "log"        "net/http")const (        CONN_HOST = "localhost"        CONN_PORT = "8080")func helloWorld(w http.ResponseWriter, r *http.Request) {        fmt.Fprintf(w, "Hello World!")}func main() {        http.HandleFunc("/", helloWorld)        err := http.ListenAndServe(CONN_HOST+":"+CONN_PORT, nil)        if err != nil {                log.Fatal("error starting http server : ", err)                return        }}執(zhí)行:go run http-server.gocurl http://localhost:8080/Hello World!但是在網(wǎng)絡(luò)瀏覽器中打開 ip 地址時(shí):http://111.111.1.1:8080/connection didn't succeed如果我替換這段代碼:        err := http.ListenAndServe(CONN_HOST+":"+CONN_PORT, nil)        if err != nil {                log.Fatal("error starting http server : ", err)                return        }和 :         log.Fatal(http.ListenAndServe(":8080", nil))所以 main() 函數(shù)僅由這兩行組成:    func main() {        http.HandleFunc("/", helloWorld)    }curl http://localhost:8080/Hello World!在網(wǎng)絡(luò)瀏覽器中:http://111.111.1.1:8080/Hello World!那么....如何使原始的簡單 http-server.go 在網(wǎng)絡(luò)瀏覽器中工作,而不僅僅是使用命令行 curl ?期待您的幫助。馬可
查看完整描述

1 回答

?
慕姐8265434

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊

你的服務(wù)器監(jiān)聽的ip地址是localhost,所以它只處理請求到localhost。

你可以嘗試curl http://111.111.1.1:8080/,你也會失敗。

如果你想從局域網(wǎng)或任何其他 IP 訪問你的服務(wù)器,你應(yīng)該設(shè)置CONN_HOST = "111.111.1.1"。


查看完整回答
反對 回復(fù) 2023-06-01
  • 1 回答
  • 0 關(guān)注
  • 125 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號