BinghamtonBetterBus-v2/src/shared/bin/server.dart
Levi Lesches e8de6475c7
Optimizations (#15)
- Add walking transfers
- Pick route with minimal walking distance, instead of stop count
- Turned `shared` into the new server, client no longer relies on `server`
- Prepare to send full route data (instead of string) to the client
2025-05-04 03:19:06 -04:00

25 lines
722 B
Dart

// User-facing script
// ignore_for_file: avoid_print
import "package:shared/generator.dart";
import "package:shared/graph.dart";
import "package:shared/server.dart" as handlers;
import "package:shelf_router/shelf_router.dart";
import "package:shelf/shelf_io.dart" as io;
Future<void> init() async {
print("Initializing...");
StopState.stops = await Generator.stops.parse();
StopState.routes = await Generator.routes.parse();
}
void main() async {
await init();
final router = Router();
router.get("/path", handlers.getPath);
router.get("/stops", handlers.getStops);
router.get("/routes", handlers.getRoutes);
await io.serve(router.call, "localhost", 8001);
print("Listening on localhost:8001");
}