Web interface: чуток упростил загрузку index.html
This commit is contained in:
@@ -29,9 +29,11 @@ bundle {
|
|||||||
'Import-Package': '*'
|
'Import-Package': '*'
|
||||||
]
|
]
|
||||||
exclude group: 'com.google.code.gson'
|
exclude group: 'com.google.code.gson'
|
||||||
|
exclude group: 'commons-io'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':core')
|
compile project(':core')
|
||||||
included group: 'com.google.code.gson', name: 'gson', version: '2.7'
|
included group: 'com.google.code.gson', name: 'gson', version: '2.7'
|
||||||
|
included group: 'commons-io', name: 'commons-io', version: '2.5'
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ package asys.webinterface;
|
|||||||
|
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
import com.sun.net.httpserver.HttpHandler;
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@@ -21,14 +22,7 @@ public class IndexHandler implements HttpHandler {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
InputStream inputStream = getClass().getResourceAsStream("/index.html");
|
InputStream inputStream = getClass().getResourceAsStream("/index.html");
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
|
htmlTemplate = IOUtils.toString(inputStream, "UTF-8");
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
String line;
|
|
||||||
while ((line = br.readLine()) != null) {
|
|
||||||
sb.append(line).append("\n");
|
|
||||||
}
|
|
||||||
htmlTemplate = sb.toString();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Error load htmlTemplate", e);
|
throw new RuntimeException("Error load htmlTemplate", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user