32 lines
1.1 KiB
Java
32 lines
1.1 KiB
Java
import java.io.BufferedReader;
|
|
import java.io.InputStreamReader;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
|
|
public class TaskManager {
|
|
public static void main(String[] args) {
|
|
try {
|
|
URL url = new URL("http://localhost:8000/get_tasks");
|
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
|
con.setRequestMethod("GET");
|
|
|
|
int status = con.getResponseCode();
|
|
if (status == 200) {
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
|
String inputLine;
|
|
StringBuffer content = new StringBuffer();
|
|
while ((inputLine = in.readLine()) != null) {
|
|
content.append(inputLine);
|
|
}
|
|
in.close();
|
|
con.disconnect();
|
|
System.out.println("Tasks: " + content.toString());
|
|
} else {
|
|
System.out.println("GET request failed with status: " + status);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|