-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrough.java
More file actions
28 lines (22 loc) · 823 Bytes
/
rough.java
File metadata and controls
28 lines (22 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpExchange;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
public class rough {
public static void main(String[] args) throws IOException {
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
server.createContext("/", new MyHandler());
server.start();
}
static class MyHandler implements HttpHandler {
@Override
public void handle(HttpExchange exchange) throws IOException {
OutputStream os = exchange.getResponseBody();
String response = "Hello, this is the response!";
os.write(response.getBytes());
os.close();
}
}
}