Follow me on GitHub

8줄짜리 그루비 웹서버

2013-01-29 07:22:48 +0000

원본 http://jadn.com/~bob/#A20100708-111851.art

HttpServer server = HttpServer.create(new InetSocketAddress(2222),0)
    server.createContext('/', { 
        HttpExchange exchange ->
        exchange.sendResponseHeaders(200,0);
        exchange.responseBody.write("hello from groovy land.".bytes)
        exchange.responseBody.close();
        i++;
    } as HttpHandler)
server.start();

복잡한 코드를 넣으려고 하면 잘 동작하지 않습니다. 8줄로도 된다는 걸 보여줄 뿐 :)


|