Arduino からHerokuアプリケーションにリクエストを送信しようとしています。返されるのは Heroku の 404 ページだけです。そこで、Python で同様のスクリプトを作成しましたが、問題なく動作します。
Arduino コード:
char serverName[] = "ruby-coffee-maker.herokuapp.com";
...
if (!client.connected()) {
Serial.println("connecting...");
if (client.connect(serverName, 80)) {
Serial.println("connected");
// Make a HTTP request
client.println("GET / HTTP/1.0");
client.println();
// Wait for response
delay(100);
// If data can be read from te server, print it
while (client.available()) {
char c = client.read();
Serial.print(c);
}
Serial.print("Done");
client.stop();
}
else {
// If you didn't get a connection to the server:
Serial.println("connection failed");
}
}
Python コード:
import httplib
h = httplib.HTTPConnection("ruby-coffee-maker.herokuapp.com")
h.request("GET", "/")
r = h.getresponse()
data = r.read()
print r.status, r.reason, "\"" + data + "\""
h.close()
この問題を解決するにはどうすればよいですか?