| | |
| | | public class MyNanoHttpServer extends NanoHTTPD { |
| | | |
| | | //声明服务端 端口 |
| | | private static final Integer HTTP_PORT = 49152; |
| | | public static final Integer HTTP_PORT = 49152; |
| | | |
| | | public MyNanoHttpServer(String hostname, int port) { |
| | | super(hostname, port); |
| | |
| | | com.alibaba.fastjson.JSONObject jsonParam = JSON.parseObject(paramStr); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | //TODO 写你的业务逻辑..... |
| | | //升级驱动文件路径 |
| | | String fileName = ((HTTPSession) session).getUri(); |
| | | String data = ""; |
| | | if (fileName.equals(HdlFileLogic.getInstance().getDriveRootPath())) { |
| | | |
| | | String ss = HdlFileLogic.getInstance().readFile(HdlFileLogic.getInstance().getLogFilePath()); |
| | | data = HdlFileLogic.getInstance().readFile(fileName); |
| | | |
| | | } |
| | | //响应客户端 |
| | | return newFixedLengthResponse(ss); |
| | | return newFixedLengthResponse(data); |
| | | // return newFixedLengthResponse("success"); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | return newFixedLengthResponse("success"); |
| | | } else if (Method.GET == session.getMethod()) { |
| | | |
| | | Map<String, List<String>> parameters = session.getParameters(); |
| | | String ss = HdlFileLogic.getInstance().readFile(HdlFileLogic.getInstance().getLogFilePath()); |
| | | //升级驱动文件路径 |
| | | String fileName = ((HTTPSession) session).getUri(); |
| | | String data = ""; |
| | | if (fileName.contains(HdlFileLogic.getInstance().getDriveRootPath())) { |
| | | data = HdlFileLogic.getInstance().readFile(fileName); |
| | | } |
| | | //响应客户端 |
| | | return newFixedLengthResponse(ss); |
| | | return newFixedLengthResponse(data); |
| | | // return newFixedLengthResponse("success"); |
| | | } |
| | | |