Permalink
Browse files

simple hello world web app example

  • Loading branch information...
1 parent 9d92287 commit fd6e0594bae4e098fe0413c22925141891b50e5a @igrigorik committed May 24, 2012
Showing with 22 additions and 1 deletion.
  1. +2 −0 README.md
  2. +20 −1 test-app/main.dart
View
2 README.md
@@ -24,6 +24,8 @@ $> git push heroku master
$> curl http://myapp_name.herokuapp.com/
```
+See `test-app` directory for the world simplest Dart web app running on Heroku: [dartvm.herokuapp.com](http://dartvm.herokuapp.com/)
+
## License
The MIT License - Copyright (c) 2012 Ilya Grigorik
View
21 test-app/main.dart
@@ -1,3 +1,22 @@
+#import('dart:io');
+#import('dart:json');
+
main() {
- print('Hello, Dart!');
+ var server = new HttpServer();
+ int port = Math.parseInt(Platform.environment['PORT']);
+ server.listen('0.0.0.0', port);
+ print('Server started on port: ${port}');
+
+ server.defaultRequestHandler = (HttpRequest request, HttpResponse response) {
+
+ var resp = JSON.stringify({
+ 'Dart on Heroku': true,
+ 'Buildpack URL': 'https://github.com/igrigorik/heroku-buildpack-dart',
+ 'Environment': Platform.environment}
+ );
+
+ response.headers.set(HttpHeaders.CONTENT_TYPE, 'application/json');
+ response.outputStream.writeString(resp);
+ response.outputStream.close();
+ };
}

0 comments on commit fd6e059

Please sign in to comment.