import io.activej.http.*; public class HttpServerExample { public static void main(String[] args) throws Exception { Eventloop eventloop = Eventloop.create().withCurrentThread(); AsyncServlet asyncServlet = request -> { String name = request.getQuery().get("name"); String message = "Hello, " + (name != null ? name : "World") + "!"; return HttpResponse.ok200().withPlainText(message); }; AsyncHttpServer httpServer = AsyncHttpServer.create(eventloop, asyncServlet); httpServer.setListenPort(8080); httpServer.listen(); eventloop.run(); } }


上一篇:
下一篇:
切换中文