| OLD | NEW |
| 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 leap_server; | 5 library leap_server; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 class Conversation { | 9 class Conversation { |
| 10 HttpRequest request; | 10 HttpRequest request; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 </head> | 87 </head> |
| 88 <body> | 88 <body> |
| 89 <h1>$title</h1> | 89 <h1>$title</h1> |
| 90 <p>$text</p> | 90 <p>$text</p> |
| 91 </body> | 91 </body> |
| 92 </html> | 92 </html> |
| 93 """; | 93 """; |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 main() { | 97 main(List<String> arguments) { |
| 98 List<String> arguments = new Options().arguments; | |
| 99 if (arguments.length > 0) { | 98 if (arguments.length > 0) { |
| 100 Conversation.landingPage = arguments[0]; | 99 Conversation.landingPage = arguments[0]; |
| 101 } | 100 } |
| 102 var host = '127.0.0.1'; | 101 var host = '127.0.0.1'; |
| 103 if (arguments.length > 1) { | 102 if (arguments.length > 1) { |
| 104 host = arguments[1]; | 103 host = arguments[1]; |
| 105 } | 104 } |
| 106 int port = 0; | 105 int port = 0; |
| 107 if (arguments.length > 2) { | 106 if (arguments.length > 2) { |
| 108 port = int.parse(arguments[2]); | 107 port = int.parse(arguments[2]); |
| 109 } | 108 } |
| 110 HttpServer.bind(host, port).then((HttpServer server) { | 109 HttpServer.bind(host, port).then((HttpServer server) { |
| 111 print('HTTP server started on http://$host:${server.port}/'); | 110 print('HTTP server started on http://$host:${server.port}/'); |
| 112 server.listen(Conversation.onRequest, onError: Conversation.onError); | 111 server.listen(Conversation.onRequest, onError: Conversation.onError); |
| 113 }).catchError((e) { | 112 }).catchError((e) { |
| 114 print("HttpServer.bind error: $e"); | 113 print("HttpServer.bind error: $e"); |
| 115 exit(1); | 114 exit(1); |
| 116 }); | 115 }); |
| 117 } | 116 } |
| OLD | NEW |