import org.restlet.Component;
import org.restlet.Restlet;
import org.restlet.data.Protocol;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.data.Status;
import org.restlet.resource.Representation;
import org.restlet.resource.StringRepresentation;

public class TestCodeDude {

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {

        Component component = new Component();
        component.getServers().add(Protocol.HTTP, 8182);

        Restlet application = new Restlet(component.getContext()) {
            @Override
            public void handle(Request request, Response response) {
                super.handle(request, response);

                Representation representation = new StringRepresentation(
                        "Your IP address = "
                                + request.getClientInfo().getAddress());
                response.setEntity(representation);
                response.setStatus(Status.SUCCESS_OK);
            }
        };
        component.getDefaultHost().attach("", application);
        // Start the server
        component.start();
    }
}
