use of com.sun.net.httpserver.HttpHandler in project PotatOs-CMSC-355 by theneims.
the class Server method startServer.
static HttpServer startServer() throws IOException {
final HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
server.stop(0);
}
}));
HttpHandler handler = RuntimeDelegate.getInstance().createEndpoint(new PotatOsServerApplication(), HttpHandler.class);
server.createContext("/", handler);
server.start();
return server;
}
Aggregations