Skip to content

Instantly share code, notes, and snippets.

@sethladd
Created August 15, 2012 05:42
Show Gist options
  • Save sethladd/3356517 to your computer and use it in GitHub Desktop.
Save sethladd/3356517 to your computer and use it in GitHub Desktop.
Dart server for Heroku
#import('dart:io');
#import('dart:json');
main() {
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,
'Hello': 'Intertubes'
});
response.headers.set(HttpHeaders.CONTENT_TYPE, 'application/json');
response.outputStream.writeString(resp);
response.outputStream.close();
};
}
web: dart main.dart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment