首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >来自Arduino的Web2Py GET请求(ESP8266WiFi)

来自Arduino的Web2Py GET请求(ESP8266WiFi)
EN

Stack Overflow用户
提问于 2018-06-29 00:25:47
回答 1查看 60关注 0票数 0

我正在使用NodeMCU,并希望将数据记录到我的本地Web2Py服务器。

请求:"http://minion.local:8000/ardulog/default/add/6476366/45643“在浏览器中运行良好,并返回一个记录id。

我的Arduino可以连接到我的服务器,但没有得到任何返回数据、错误或其他信息,并且我的数据库中没有任何内容。

代码语言:javascript
复制
// This will send the request to the server
samptime = millis();
rpm = (samptime + 333) % 96789;
String request = "10.0.0.244:8000/ardulog/default/add/"+String(samptime)+"/"+String(rpm)+" HTTP/1.1";
Serial.println("\ntrying: ");
Serial.println("GET " + request);
Serial.println("host: minion.local");
client.println("GET " + request);
client.println("host: minion.local");

// if there are incoming bytes available 
// from the server, read them and print them:
while (client.available()) {
  char c = client.read();
  Serial.print(c);
}

Serial.println("closing connection");
client.stop(); 

我尝试了我能想到的所有变体,但只得到了以下几点:

代码语言:javascript
复制
connecting to minion.local
[hostByName] request IP for: minion.local
[hostByName] Host: minion.local IP: 10.0.0.244
Requesting: 
GET 10.0.0.244:8000/ardulog/default/add/112725/16269 HTTP/1.1
host: minion.local
closing connection
wait 5 sec...

为什么我没有读取从服务器返回的任何内容?

EN

回答 1

Stack Overflow用户

发布于 2018-06-29 03:56:27

解决了!尽管我在Google上的POSTing失败了,但只需将单词从GET改为POST就可以在Web2Py上工作,而不会发送任何正文数据:

代码语言:javascript
复制
if(client.connect(host,port))  
  client.println("POST /ardulog/default/add/" + String(samptime)+ "/" + String(rpm) + " HTTP/1.1");

(仍然没有收到来自服务器的结果页面)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51087602

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档