Added Http Server
Former-commit-id: 1dcc03532d6cd8c5ff470f3ad7c05224c1f4af54
This commit is contained in:
parent
7b6e1e2d7a
commit
fab111a6cb
4 changed files with 40 additions and 1 deletions
9
resource/index.tmpl
Normal file
9
resource/index.tmpl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -4,8 +4,11 @@ package se.koc.hal;
|
|||
import se.koc.hal.deamon.DataAggregatorDaemon;
|
||||
import se.koc.hal.deamon.HalDaemon;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.io.file.FileUtil;
|
||||
import zutil.log.CompactLogFormatter;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.net.http.HttpServer;
|
||||
import zutil.net.http.pages.HttpFilePage;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.logging.Level;
|
||||
|
|
@ -35,5 +38,9 @@ public class PowerChallenge {
|
|||
for(HalDaemon daemon : daemons){
|
||||
daemon.initiate(daemonTimer);
|
||||
}
|
||||
|
||||
HttpServer http = new HttpServer(8080);
|
||||
http.setDefaultPage(new HttpFilePage(FileUtil.find("resource/")));
|
||||
http.setPage("/", new PowerChallengeHttpPage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
23
src/se/koc/hal/PowerChallengeHttpPage.java
Normal file
23
src/se/koc/hal/PowerChallengeHttpPage.java
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package se.koc.hal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import zutil.net.http.HttpHeaderParser;
|
||||
import zutil.net.http.HttpPage;
|
||||
import zutil.net.http.HttpPrintStream;
|
||||
import zutil.parser.Templator;
|
||||
|
||||
public class PowerChallengeHttpPage implements HttpPage {
|
||||
|
||||
@Override
|
||||
public void respond(HttpPrintStream out, HttpHeaderParser client_info,
|
||||
Map<String, Object> session, Map<String, String> cookie,
|
||||
Map<String, String> request) throws IOException {
|
||||
|
||||
Templator tmpl = new Templator("resource/index.tmpl");
|
||||
|
||||
out.print(tmpl.compile());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ public class DataAggregatorDaemon extends TimerTask implements HalDaemon {
|
|||
new DayAggregator());
|
||||
|
||||
|
||||
logger.fine("Done aggrigating");
|
||||
logger.fine("Done aggregation");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue