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

Side by Side Diff: dart/pkg/dart2js_incremental/lib/server.dart

Issue 858833002: Add server options. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Move Options to own library. Created 5 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/pkg/dart2js_incremental/lib/src/options.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js_incremental.server; 5 library dart2js_incremental.server;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'dart:async' show 9 import 'dart:async' show
10 Future, 10 Future,
11 Stream; 11 Stream;
12 12
13 import 'dart:convert' show 13 import 'dart:convert' show
14 HtmlEscape, 14 HtmlEscape,
15 JSON, 15 JSON,
16 UTF8; 16 UTF8;
17 17
18 import 'src/options.dart';
19
18 class Conversation { 20 class Conversation {
19 HttpRequest request; 21 HttpRequest request;
20 HttpResponse response; 22 HttpResponse response;
21 23
22 static const String PACKAGES_PATH = '/packages'; 24 static const String PACKAGES_PATH = '/packages';
23 25
24 static const String CONTENT_TYPE = HttpHeaders.CONTENT_TYPE; 26 static const String CONTENT_TYPE = HttpHeaders.CONTENT_TYPE;
25 27
26 static Uri documentRoot = Uri.base; 28 static Uri documentRoot = Uri.base;
27 29
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 <body> 155 <body>
154 <h1>$title</h1> 156 <h1>$title</h1>
155 <p style='white-space:pre'>$text</p> 157 <p style='white-space:pre'>$text</p>
156 </body> 158 </body>
157 </html> 159 </html>
158 """; 160 """;
159 } 161 }
160 } 162 }
161 163
162 main(List<String> arguments) { 164 main(List<String> arguments) {
163 if (arguments.length > 0) { 165 Options options = Options.parse(arguments);
164 Conversation.documentRoot = Uri.base.resolve(arguments[0]); 166 if (options == null) {
167 exit(1);
165 } 168 }
166 var host = '127.0.0.1'; 169 if (!options.arguments.isEmpty) {
167 if (arguments.length > 1) { 170 Conversation.documentRoot = Uri.base.resolve(options.arguments.single);
168 host = arguments[1];
169 } 171 }
170 int port = 0; 172 Conversation.packageRoot = options.packageRoot;
171 if (arguments.length > 2) { 173 String host = options.host;
172 port = int.parse(arguments[2]); 174 int port = options.port;
173 }
174 if (arguments.length > 3) {
175 Conversation.packageRoot = Uri.base.resolve(arguments[4]);
176 }
177 HttpServer.bind(host, port).then((HttpServer server) { 175 HttpServer.bind(host, port).then((HttpServer server) {
178 print('HTTP server started on http://$host:${server.port}/'); 176 print('HTTP server started on http://$host:${server.port}/');
179 server.listen(Conversation.onRequest, onError: Conversation.onError); 177 server.listen(Conversation.onRequest, onError: Conversation.onError);
180 }).catchError((e) { 178 }).catchError((e) {
181 print("HttpServer.bind error: $e"); 179 print("HttpServer.bind error: $e");
182 exit(1); 180 exit(1);
183 }); 181 });
184 } 182 }
OLDNEW
« no previous file with comments | « no previous file | dart/pkg/dart2js_incremental/lib/src/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698