Skip to content

Commit

Permalink
simple hello world web app example
Browse files Browse the repository at this point in the history
  • Loading branch information
igrigorik committed May 24, 2012
1 parent 9d92287 commit fd6e059
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 20 additions & 1 deletion test-app/main.dart
Original file line number Diff line number Diff line change
@@ -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.