Ein minimalistischer HTTP-Server
ulrich
2021-03-27 6d3836e41493f89c5b8700cca34111319e9fa41a
src/de/uhilger/minsrv/Server.java
@@ -38,7 +38,7 @@
  private static final Logger logger = Logger.getLogger(Server.class.getName());
  
  public static final String STR_SLASH = "/";
  public static final String CMD_SERVER_STOP = "/server/stop";
  
  private int port;
  
@@ -85,8 +85,8 @@
    logger.info("Server starting on port " + port);
    HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
    server.createContext(ctx + "/av", new FileHandler(App.getInitParameter(App.IP_WWW_DATA)));
    server.createContext(ctx + "/server/stop", new StopServerHandler());
    server.createContext(ctx + STR_SLASH, new FileHandler(App.getInitParameter(App.IP_WWW_DATA)));
    server.createContext(ctx + CMD_SERVER_STOP, new StopServerHandler());
    server.setExecutor(Executors.newFixedThreadPool(20));
    server.start();
  }