-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathHelloWorldExample.java
More file actions
27 lines (22 loc) · 897 Bytes
/
HelloWorldExample.java
File metadata and controls
27 lines (22 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package examples.helloworld;
import com.vtence.molecule.Response;
import com.vtence.molecule.WebServer;
import java.io.IOException;
/**
* In this example, we run a single application that responds <i>Hello, World!</i> to all incoming requests.
* This is as simple as it can get.
*/
public class HelloWorldExample {
public void run(WebServer server) throws IOException {
// Start the default web server and provide a single application, which
// responds to all incoming requests.
server.start(request -> Response.ok().done("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());
}
}