Package examples.helloworld

Source Code of examples.helloworld.HelloWorldExample

package examples.helloworld;

import com.vtence.molecule.Application;
import com.vtence.molecule.Request;
import com.vtence.molecule.Response;
import com.vtence.molecule.WebServer;

import java.io.IOException;

public class HelloWorldExample {

    public void run(WebServer server) throws IOException {
        server.start(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body("Hello, World!");
            }
        });
    }

    public static void main(String[] args) throws IOException {
        HelloWorldExample example = new HelloWorldExample();
        // Run the default web server
        WebServer webServer = WebServer.create();
        example.run(webServer);
        System.out.println("Access at " + webServer.uri());
    }
}
TOP

Related Classes of examples.helloworld.HelloWorldExample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.