Implemented read json courses

This commit is contained in:
Marcel Kapfer (mmk2410) 2016-07-17 23:41:24 +02:00
parent a1de036338
commit fc5c786b00
4 changed files with 47 additions and 28 deletions

View file

@ -6,6 +6,8 @@ import 'package:logging/logging.dart';
import 'package:rpc/rpc.dart';
import '../lib/server/titamaapi.dart';
import '../lib/server/titamaio.dart';
import '../lib/common/messages.dart';
final ApiServer _apiServer = new ApiServer(prettyPrint: true);
@ -14,7 +16,10 @@ main() async {
..level = Level.INFO
..onRecord.listen(print);
_apiServer.addApi(new TitamaApi());
// read saved data
List<Course> courses = await new TitamaIo().readJson();
_apiServer.addApi(new TitamaApi(courses));
HttpServer server = await HttpServer.bind(InternetAddress.ANY_IP_V4, 8080);
server.listen(_apiServer.httpRequestHandler);