任何人都可以引導我正確的方向,當涉及到HTTP請求與Python?我所追求的是一個Excel-VBA加載項,它將跟蹤用戶打開哪些工作簿以及何時等。雖然已經完成,但現在我想將信息提供給數據庫。HTTP請求(Python + VBA)
爲此我能想象運行這將被用來存儲的信息很簡單的Python服務器。因此,問題是,我如何設置一個簡單的http服務器,以便VBA可以發佈一個簡單的字符串然後存儲?
謝謝!
編輯:
謝謝chf!我繼續跟着你的建議 - 我用django替換了燒瓶,因爲我有一些簡短的經驗。我已經創建了我的第一個現在創建的API,但不能發佈使用您發佈的VBA代碼。我可以做httpie像這樣: 「HTTP POST HTTP:/127.0.0.1名=」 somename」 workbookname = 「someworkbook」
Sub TestFramework()
Dim newClient As New WebClient
Dim newRequest As New WebRequest
Dim Response As WebResponse
newClient.BaseUrl = "http://127.0.0.1:8000/api/create/"
newRequest.Method = HttpPost
newRequest.Format = WebFormat.plaintext
newRequest.AddBodyParameter "name", "somename"
newRequest.AddBodyParameter "workbook_name", "Sheet1"
Set Response = newClient.Execute(newRequest)
End Sub
你可能指向我正確的方式任何機會
?RuntimeError: You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 127.0.0.1:8000/api/create/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings. [03/Aug/2016 20:13:18] "POST /api/create HTTP/1.1" 500 60534
EDIT2:請不要介意,得到它的工作:)