All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fordream.http.SimplyDreamHttpd Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
package fordream.http;

import fordream.http.handler.StaticResourcesHandler;

/**
 * A simple to use DreamHttpd
 */
public class SimplyDreamHttpd extends DreamHttpd {
    public SimplyDreamHttpd(int port, String webRoot) {
        super(port, webRoot);
        this.registerHandler(new StaticResourcesHandler()); // register a static resource handler
    }

    public static void main(String[] args) throws Exception {
        int port = -1;
        String root = null;
        // set http server port
        if (args.length > 0)
            port = Integer.valueOf(args[0]);
        else
            port = 2046;

        // set http server root url
        if (args.length > 1)
            root = args[1];
        else
            root = System.getProperty("user.dir");

        DreamHttpd httpd = new SimplyDreamHttpd(port, root); // init
        httpd.start(); // start the server

        System.out.println(String.format("Start Http Server with %d and %s", port, root));

        System.out.println("Press Ctrl + C to exit.");

        while (true) System.in.read();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy