cobweb/src/Cobweb.java

31 lines
735 B
Java

package cobweb;
import com.spookyinternet.cobweb.*;
public class Cobweb {
private static final int PORT = 4815;
private static final byte[] HOST = { 127, 0, 0, 1 };
public static void main(String[] args) {
CobwebServer srv = new CobwebServer(PORT, HOST);
srv.on("get", "/hello/{?name}", (req) -> {
if(req.params.length > 0) {
return new HttpStaticResponse("Hello, " + req.params[0] + "!");
} else {
return new HttpStaticResponse("Hello, world!");
}
});
/*
srv.on("get", "/redirect", HttpPermanentRedirect("https://www.example.com"));
srv.on("get", "/*", WwwDir(WWW_DIR, [
AllowTrailingSlash,
AllowImpliedIndex,
AllowDirectoryListing
]));
*/
}
}