Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Unified Diff: hello/bin/server.dart

Issue 367903008: Create a set of Dart dockerfiles (Closed) Base URL: https://github.com/dart-lang/dart_docker.git@master
Patch Set: Update Dart version and dart-hello readme Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « hello/README.md ('k') | hello/pubspec.lock » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: hello/bin/server.dart
diff --git a/hello/bin/server.dart b/hello/bin/server.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4b5935b1b81a8753ea5c10dbaa1f77c42ee4509d
--- /dev/null
+++ b/hello/bin/server.dart
@@ -0,0 +1,31 @@
+import 'dart:async';
+import 'dart:io';
+
+import 'package:http_server/http_server.dart';
+
+void main() {
+ var webFiles = new VirtualDirectory('web');
+
+ runZoned(() {
+ HttpServer.bind('0.0.0.0', 8080).then((server) {
+ server.listen((request) {
+ if (request.uri.path == '/') {
+ request.response.redirect('/index.html');
+ } else if (request.uri.path == '/version') {
+ request.response.headers..contentType = ContentType.TEXT;
+ request.response
+ ..writeln('Dart version: ${Platform.version}')
+ ..writeln('Dart executable: ${Platform.executable}')
+ ..writeln('Dart executable arguments: '
+ '${Platform.executableArguments}')
+ ..close();
+ } else {
+ webFiles.serveRequest(request);
+ }
+ });
+ });
+ },
+ onError: (e, stackTrace) {
+ print('Error processing request $e\n$stackTrace');
+ });
+}
« no previous file with comments | « hello/README.md ('k') | hello/pubspec.lock » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698