12345678910111213141516171819202122232425262728293031 |
- package me.yoqi.android.nanohttpdemo.net;
- import fi.iki.elonen.NanoHTTPD;
- /**
- * @author liuyuqi.gov@msn.cn
- * @date 12/18/2020
- */
- public class LocalHttpService extends NanoHTTPD {
- /**
- * 覆写构造方法
- *
- * @param port
- */
- public LocalHttpService(int port) {
- super(port);
- }
- @Override
- public Response serve(IHTTPSession session) {
- StringBuilder builder = new StringBuilder();
- builder.append("<!DOCTYPE html><html><body>");
- builder.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
- builder.append("\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"/>\n" +
- " \t<meta content=\"width=device-width,initial-scale=1.0\" name=\"viewport\">");
- builder.append("服务已经启动啦,可以正常使用啦!");
- builder.append("</body></html>\n");
- return newFixedLengthResponse(builder.toString());
- }
- }
|