2017-10-07 96 views
1

我已經在我的Github存儲庫中創建了一個Webhook。我已將我的有效負載URL設置爲: localhost:4567 /有效負載如何實現Django的服務器來偵聽來自Webhook的POST請求?我正在使用NGROK將我的本地主機公開到互聯網上

由於我使用本地主機,因此需要將其公開到Internet。爲此,我正在使用ngrok,並且我也執行了此命令: ./ngrok http 4567

我遵循此鏈接中編寫的所有步驟來創建成功的webhook,以便在任何提交操作時接收通知在存儲庫中完成。

鏈接=>https://developer.github.com/webhooks/configuring/

我使用Django框架接收來自網絡掛接POST請求。但是,在上面的鏈接給出的教程中,他們使用了Sinatra(在Ruby中創建Web應用程序)。我不熟悉Ruby。我希望繼續在Django工作,那麼你能幫我解決一下如何使用Django的服務器來監聽來自Webhook的POST請求?

到目前爲止,我所做的,我的Webhook中有以下錯誤。在「響應」下面給出:

<!doctype html5> 
<html> 
<head> 
<style type="text/css"> 

    strong { font-weight: bold; } 
    hr { -moz-box-sizing: content-box; box-sizing: content-box; height: 0; } 
    html { font-family: sans-serif; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; } body { margin: 0; } 
    a { background-color: transparent; } 
    a:active, a:hover { outline: 0; } 
    </style> 

    <style type="text/css"> 
     body { background-color: #f5f5f5; } 
     .container { width: 500px; margin: auto; color: #444; padding: 5px; } 
     a, strong { color: purple; text-decoration: none; } 
     a:hover { text-decoration: underline; } 
     h2 { text-align: center; color: #000; } 
     p { line-height: 20px; } 
    </style> 
</head> 
<body> 
    <div class="container"> 


<h2>Failed to complete tunnel connection</h2> 
<hr /> 
<p> 
The connection to <strong><a    
href="http://ac448203.ngrok.io">http://ac448203.ngrok.io</a></strong> 
was successfully tunneled to your ngrok client, 
but the client failed to establish a connection to 
the local address <strong><a href="http://localhost:80">localhost:80</a>    
</strong>. 
</p> 
<p> 
Make sure that a web service is running on 
<strong><a href="http://localhost:80">localhost:80</a></strong> and that it 
is a valid address. 
</p> 
<p> 
The error encountered was: <strong style="color: #9E2929">dial tcp [::1]:80: 
connectex: No connection could be made because the target machine actively 
refused it.</strong> 
</p>} 


    </div> 
</body> 
</html>  
+0

能告訴你我們可以輕鬆截取屏幕截圖中的請求和響應。你可以模糊任何祕密 –

+0

@CliveMakamara其實我是新來堆棧溢出,所以我不知道如何張貼在這個平臺上的照片。對不起。我將發佈響應部分。謝謝。 –

+0

不用擔心我也只是一個月的會員。我只需要更多的信息來幫助你 –

回答

0

的錯誤是在你的ngrok設置它試圖連接端口80。嘗試不同的版本ngrok的或確保你是真正運行ngrok http 4567

+0

是的,我做了很多次(ngrok http 4567)。 我還沒有嘗試不同版本的ngrok。我想我應該嘗試一下。非常感謝你@Clive。 –

相關問題