所以我对C#真的很生气。我正在尝试执行GET http请求,但我的响应总是空白/ null。这是我的代码
class ServerUtil
{
String status = "";
public String serverMessage(String query)
{
serverMessageHelper(query);
return status;
}
private async void serverMessageHelper(String query)
{
UriBuilder baseUri = new UriBuilder("http://darksync-anarchysystems.rhcloud.com/ServletExample/ServletExample?");
baseUri.Query = baseUri.Query.Substring(1) + query;
string url = baseUri.Uri.ToString();
var httpClient = new HttpClient(new HttpClientHandler());
HttpResponseMessage response = await httpClient.GetAsync(url);
try
{
response.EnsureSuccessStatusCode();
status = await response.Content.ReadAsStringAsync();
}
catch
{
status = "505";
}
}
}
我创建一个ServerUtil对象,并在代码
中进行服务器调用ServerUtil s = new ServerUtil();
string resp = s.serverMessage("action=login&user=" + username + "&password=" + password);
奇怪的是它在我的服务器上进行了更改,但没有响应..
答案 0 :(得分:0)
我测试了以下内容并正确获得状态响应。
import time
import os
# turn off the default trigger of the green LED
os.system("sudo bash -c \"echo none > /sys/class/leds/led0/trigger\"")
# turn on the green LED
os.system("sudo bash -c \"echo 1 > /sys/class/leds/led0/brightness\"")
# keep it on 5 seconds
time.sleep(5)
# turn off the green LED on PI
os.system("sudo bash -c \"echo 0 > /sys/class/leds/led0/brightness\"")