xitiomet / placebohttp (http://openstatic.org/)

Embeded Http server for gcj/java applications. PlaceboHttp uses an automatic session management system, Treating each session as a HttpRequest queue.

Clone this repository (size: 135.2 KB): HTTPS / SSH
$ hg clone http://hg.openstatic.org/placebohttp
commit 19: 81f8f47a533a
parent 18: 00cf4ae79f6b
branch: default
Got swing interface working 100 percent
xitiomet
9 months ago
placebohttp / src / PlaceboBase.java
r19:81f8f47a533a 76 loc 2.3 KB embed / history / annotate / raw /
import org.openstatic.placebo.CoreServer;
import org.openstatic.placebo.ControlPanel;

public class PlaceboBase
{
    public static void help()
    {
        System.err.println("Openstatic.org HTTP Server");
        System.err.println("");
        System.err.println("  --debug                        Turn debugging output on.");
        System.err.println("  --root [path]                  Set webroot");
        System.err.println("  --port [port]                  Specify HTTP listening port");
        System.err.println("  --help                         display this menu");
        System.err.println("  --swing                        Start up in swing control panel");
        System.err.println("");
        System.err.println("");
    }
    
    public static void main(String[] args)
    {
        int http_port = 80;
        boolean debug = false;
        String web_root = "placebohttp.jar/www";
        boolean start_engine = true;
        
        for (int i = 0; i < args.length; i++)
        {
            String arg = args[i].toLowerCase();
            String arg_p1 = null;
            if (i + 1 < args.length)
            {
                arg_p1 = args[i+1];
            }
            
            if (arg.equals("--port"))
            {
                http_port = Integer.valueOf(arg_p1);
            }

            if (arg.equals("--help"))
            {
                help();
                System.exit(0);
            }
            
            if (arg.equals("--root"))
            {
                web_root = arg_p1;
            }
            
            if (arg.equals("--debug"))
            {
                System.err.println("Openstatic.org Placebo HTTP Server");
                System.err.println("----------------------------------");
                debug = true;
            }
            
            if (arg.equals("--swing"))
            {
                ControlPanel cp = new ControlPanel();
                cp.setPort(http_port);
                cp.setWebRoot(web_root);
                cp.setDebug(debug);
            }
        }
        
        if (start_engine)
        {
            CoreServer x = new CoreServer();
            x.setPort(http_port);
            x.setWebRoot(web_root);
            x.setDebug(debug);
            x.start();
        }
    }
    
}