package javahttpserver;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executors;
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
/**
* @for ProSoft ID Dept., Audio Player - Java HTTP Server
* @author Donald Duvall
* @date 2013-01-07
*
* @description
* This Java HTTP Server should receive a GET request from the Motion Sensor
* Arduino Client and then play a sound file.
*/
public class JavaHTTPServer {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
InetSocketAddress addr = new InetSocketAddress(80);
HttpServer server = HttpServer.create(addr, 0);
server.createContext("/lightSound", new LightHandler());
server.createContext("/speakSound", new SpeakHandler());
server.setExecutor(Executors.newCachedThreadPool());
server.start();
System.out.println("Server is listening on port 80");
}
}