platform/performance/hello/raw.dart

29 lines
608 B
Dart
Raw Normal View History

2017-08-03 17:52:10 +00:00
/// A basic server that prints "Hello, world!"
library performance.hello;
import 'dart:io';
import 'dart:isolate';
main() {
for (int i = 0; i < Platform.numberOfProcessors - 1; i++)
Isolate.spawn(start, i + 1);
start(0);
}
void start(int id) {
HttpServer
2018-06-08 07:06:26 +00:00
.bind('127.0.0.1', 3000, shared: true)
2017-08-03 17:52:10 +00:00
.then((server) {
print(
'Instance #$id listening at http://${server.address.address}:${server.port}');
server.listen((request) {
if (request.uri.path == '/') {
request.response.write('Hello, world!');
}
request.response.close();
});
});
}