Created
August 15, 2012 05:42
-
-
Save sethladd/3356517 to your computer and use it in GitHub Desktop.
Dart server for Heroku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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(); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: dart main.dart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://blog.sethladd.com/2012/08/running-dart-in-cloud-with-heroku.html