| OLD | NEW |
| (Empty) | |
| 1 --- |
| 2 layout: tutorial |
| 3 title: "Weigh Anchor: Deploy a Server and App" |
| 4 description: "Deploy a Dart server and serve a Dart app." |
| 5 has-permalinks: true |
| 6 tutorial: |
| 7 id: buildanddeploy |
| 8 js: |
| 9 - url: /js/os-switcher.js |
| 10 defer: true |
| 11 - url: /js/editor-downloads-analytics.js |
| 12 defer: true |
| 13 - url: /js/editor-version.js |
| 14 defer: true |
| 15 header: |
| 16 css: ["/codelabs/darrrt/darrrt.css"] |
| 17 --- |
| 18 |
| 19 # {{ page.title }} |
| 20 |
| 21 <div style="font-size:64px;font-weight:bold;color:#DCDCDC"> |
| 22 BETA |
| 23 </div> |
| 24 |
| 25 Please send feedback to [dartbug.com](http://dartbug.com/new). |
| 26 |
| 27 <hr> |
| 28 |
| 29 In this code lab, you deploy an client application (web app) to the Heroku hosti
ng service. |
| 30 This code lab focuses on the server-side programming aspect of this project. |
| 31 |
| 32 <div class="trydart-note" markdown="1"> |
| 33 <strong>Note:</strong> |
| 34 This code lab is for those who want to learn |
| 35 how to write a DIY server for deploying a web app. |
| 36 If you are not interested in server-side programming, |
| 37 this code lab is probably not for you. |
| 38 Perhaps you'd prefer the |
| 39 [Avast, Ye Pirates](/codelabs/darrrt/) code lab |
| 40 for building a web app. |
| 41 </div> |
| 42 |
| 43 To put your client app on the internet, you need to deploy it. |
| 44 For that, you need a client app, a web server, and a hosting service. |
| 45 |
| 46 <div class="trydart-step-details" markdown="1"> |
| 47 |
| 48  |
| 49 |
| 50 </div> |
| 51 |
| 52 You can use any web server to serve your Dart client app. |
| 53 But Dart runs on the server-side as well as on the client-side, |
| 54 so you can use Dart for both your client app and your web server. |
| 55 One benefit of doing so is that the client and web server |
| 56 can share code. |
| 57 The Dart Virtual machine (Dart VM) runs on Windows, Linux, or Mac systems. |
| 58 |
| 59 * **Web Server**—In this code lab, you learn how to build a web server in
Dart |
| 60 that can serve static files (those that have no dynamic content). |
| 61 You use this web server to respond to HTTP requests for the web app's pages. |
| 62 |
| 63 * **Host**—In addition to a web server, you need a host for your web app. |
| 64 Many public hosting services are available. |
| 65 We chose the Heroku hosting service for this project |
| 66 because it has a free tier and is easy to use. |
| 67 |
| 68 * **Client App**—As for the client app, |
| 69 you will be deploying the Pirate Badge web app from the |
| 70 [Avast, Ye Pirates](/codelabs/darrrt/) code lab. |
| 71 |
| 72 * **Fun debugging on mobile devices**—In addition, |
| 73 you learn how to use DevTools to inspect and debug your app on a mobile device. |
| 74 |
| 75 <hr> |
| 76 |
| 77 <div markdown="1"> |
| 78 |
| 79 ## Contents |
| 80 |
| 81 * [Step 0: Set up](#step-zero) |
| 82 * [Step 1: Run the app in Dartium](#step-one) |
| 83 * [Step 2: Build the app and run as JavaScript](#step-two) |
| 84 * [Step 3: Walk through the static file server's code](#step-three) |
| 85 * [Step 4: Inspect your app on a mobile device](#step-four) |
| 86 * [Step 5: Deploy to Heroku](#step-five) |
| 87 * [Step 6: Run the app on the web and on a mobile device](#step-six) |
| 88 * [What next?](#what-next) |
| 89 * [Resources](#resources) |
| 90 |
| 91 </div> |
| 92 |
| 93 <hr> |
| 94 |
| 95 ##Step 0: Set up {#step-zero} |
| 96 |
| 97 In this step, you download Dart and get the code for the app that you will be de
ploying. |
| 98 This code lab uses Dart Editor. |
| 99 |
| 100 ### <i class="fa fa-anchor"> </i> Get Dart. |
| 101 |
| 102 <div class="trydart-step-details" markdown="1"> |
| 103 If you haven't already done so, |
| 104 get the Dart download. |
| 105 Unzip the ZIP file, which creates a directory called `dart`. |
| 106 |
| 107 <!--style here is a hack to remove the arrow, which was only partially showing.
--> |
| 108 <div style="padding-left: 10px"> |
| 109 {% include downloads/_dart-editor.html buttonclass="btn btn-primary btn-lg" %} |
| 110 </div> |
| 111 |
| 112 <p class="os-choices" markdown="1"> |
| 113 The Dart tools |
| 114 work in recent versions of |
| 115 {% include os-choices.html %} |
| 116 </p> |
| 117 </div> |
| 118 |
| 119 ### <i class="fa fa-anchor"> </i> Start Dart Editor. |
| 120 |
| 121 <div class="trydart-step-details" markdown="1"> |
| 122 Go to the `dart` directory and double-click **DartEditor**. |
| 123 |
| 124 **Got questions? Having trouble?** Go to the |
| 125 [Troubleshooting Dart Editor](/tools/editor/troubleshoot.html) page. |
| 126 |
| 127 </div> |
| 128 |
| 129 ### <i class="fa fa-anchor"> </i> Get the code. |
| 130 |
| 131 <div class="trydart-step-details" markdown="1"> |
| 132 <a href="https://github.com/marycampione/deploy-codelab/archive/master.zip">Down
load</a> |
| 133 the code for the app that you will be deploying. |
| 134 Unzip the ZIP file, |
| 135 which creates a directory called `deploy-codelab`. |
| 136 </div> |
| 137 |
| 138 ### <i class="fa fa-anchor"> </i> Open deploy-codelab. |
| 139 |
| 140 <div class="trydart-step-details" markdown="1"> |
| 141 In Dart Editor, |
| 142 use **File > Open Existing Folder...** |
| 143 to open the `deploy-codelab` directory. |
| 144 </div> |
| 145 |
| 146 <div class="row"> <div class="col-md-7" markdown="1"> |
| 147 |
| 148  |
| 149 |
| 150 <div class="trydart-note" markdown="1"> |
| 151 <strong>Note:</strong> |
| 152 If you see <span style="color:red">red X's</span> at the left of the |
| 153 filenames, |
| 154 the packages are not properly installed. |
| 155 Right click `pubspec.yaml` and select **Pub Get**. |
| 156 </div> |
| 157 |
| 158 </div> <div class="col-md-5" markdown="1"> |
| 159 |
| 160 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 161 |
| 162 * The `packages` directory contains links to 3rd party libraries. |
| 163 Those libraries are defined as dependencies in the `pubspec.yaml` file. |
| 164 The `pubspec.lock` file specifies the exact versions |
| 165 of the packages required by this app. |
| 166 |
| 167 * The `web` directory contains the Pirate Badge app to deploy. |
| 168 |
| 169 * The `bin` directory contains Dart scripts that run from the command line. |
| 170 For example, scripts that run web servers live in `bin`. |
| 171 |
| 172 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 173 |
| 174 </div> </div> |
| 175 |
| 176 <hr> |
| 177 |
| 178 ##Step 1: Run the app in Dartium {#step-one} |
| 179 |
| 180 Open the code for the Pirate Badge web app and run it locally. |
| 181 |
| 182 ### <i class="fa fa-anchor"> </i> Expand the `web` directory. |
| 183 |
| 184 <div class="trydart-step-details" markdown="1"> |
| 185 In Dart Editor, expand the `web` directory |
| 186 by clicking the little arrow |
| 187  to the left of its name. |
| 188 The directory contains four files: |
| 189 |
| 190  |
| 191 |
| 192 </div> |
| 193 |
| 194 ### <i class="fa fa-anchor"> </i> Look at `piratebadge.html`. |
| 195 |
| 196 <div class="row"> <div class="col-md-7"> |
| 197 |
| 198 <div class="trydart-step-details" markdown="1"> |
| 199 |
| 200 Double-click `piratebadge.html` to open it. |
| 201 |
| 202 {% prettify html %} |
| 203 ... |
| 204 <head> |
| 205 <meta charset="utf-8"> |
| 206 <title>Pirate badge</title> |
| 207 [[highlight]]<meta name="viewport"[[/highlight]] |
| 208 [[highlight]]content="width=device-width, initial-scale=1.0">[[/highligh
t]] |
| 209 <link rel="stylesheet" href="piratebadge.css"> |
| 210 </head> |
| 211 <body> |
| 212 ... |
| 213 [[highlight]]<script type="application/dart" src="piratebadge.dart"></script>[
[/highlight]] |
| 214 [[highlight]]<script src="packages/browser/dart.js"></script>[[/highlight]] |
| 215 |
| 216 ... |
| 217 </body> |
| 218 ... |
| 219 {% endprettify %} |
| 220 |
| 221 </div> |
| 222 |
| 223 <div class="trydart-filename">piratedbadge.dart</div> |
| 224 |
| 225 </div> <div class="col-md-5" markdown="1"> |
| 226 |
| 227 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 228 |
| 229 * The <code><meta></code> tag sets attributes to |
| 230 make the app scale correctly on mobile devices. |
| 231 |
| 232 * The first `script` tag identifies the script, |
| 233 `piratebadge.dart`, that contains the web app. |
| 234 |
| 235 * `dart.js` is a script that determines if the browser supports Dart, |
| 236 and if it does, runs the app natively. |
| 237 If it does not, the script loads the JavaScript version of the app. |
| 238 |
| 239 * `dart.js` is part of the `browser` pub package. |
| 240 |
| 241 </div></div> |
| 242 |
| 243 ### <i class="fa fa-anchor"> </i> Run the app. |
| 244 |
| 245 |
| 246 <div class="row"> <div class="col-md-7"> |
| 247 |
| 248 <div class="trydart-step-details" markdown="1"> |
| 249 |
| 250 Right-click `piratebadge.html` |
| 251 and choose **Run in Dartium** from the menu. |
| 252 |
| 253  |
| 254 |
| 255 </div> |
| 256 |
| 257 </div> <div class="col-md-5" markdown="1"> |
| 258 |
| 259 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 260 |
| 261 * Dart Editor launches *Dartium*—a special build of Chromium |
| 262 that has the Dart Virtual Machine built in—and loads the app. |
| 263 |
| 264 * At this time, Dartium is the only browser that has the Dart VM built in. |
| 265 To run a Dart app in other browsers you need to convert it to JavaScript, |
| 266 which you do in the next step. |
| 267 |
| 268 </div></div> |
| 269 |
| 270 <div class="row"> <div class="col-md-7"> |
| 271 |
| 272 <div class="trydart-step-details" markdown="1"> |
| 273 |
| 274 </div> |
| 275 |
| 276 <iframe class="running-app-frame" |
| 277 style="height:220px;width:550px;margin-top:20px;margin-bottom:20px" |
| 278 src="/codelabs/darrrt/examples/6-piratebadge/piratebadge.html"> |
| 279 </iframe> |
| 280 |
| 281 </div> <div class="col-md-5" markdown="1"> |
| 282 |
| 283 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 284 |
| 285 * The Pirage Badge app should appear. |
| 286 |
| 287 * Try out the app running to the left. |
| 288 Click the button or type in the text field to generate a pirate name. |
| 289 |
| 290 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 291 |
| 292 </div></div> |
| 293 |
| 294 <hr> |
| 295 |
| 296 ##Step 2: Build the app and run as JavaScript {#step-two} |
| 297 |
| 298 In this step, you use `pub build` to |
| 299 generate the assets for the app |
| 300 and put them into a new directory named `build`. |
| 301 In addition to other tasks, |
| 302 this process generates minified JavaScript that |
| 303 works in any modern browser. |
| 304 |
| 305 ### <i class="fa fa-anchor"> </i> Check out pubspec.yaml |
| 306 |
| 307 <div class="row"> <div class="col-md-7"> |
| 308 |
| 309 <div class="trydart-step-details" markdown="1"> |
| 310 |
| 311 Double-click the `pubspec.yaml` file to open it. |
| 312 Click the **Source** tab at the bottom of the editing pane. |
| 313 The packages listed under dependencies *must* be installed |
| 314 to run the app. |
| 315 Packages are installed in one or more `packages` directories, as needed. |
| 316 |
| 317 {% prettify dart %} |
| 318 name: deploy_codelab |
| 319 description: A sample deployment |
| 320 dependencies: |
| 321 [[highlight]]browser: any[[/highlight]] |
| 322 [[highlight]]http_server: any[[/highlight]] |
| 323 [[highlight]]path: any[[/highlight]] |
| 324 {% endprettify %} |
| 325 |
| 326 </div> |
| 327 |
| 328 <div class="trydart-filename">pubspec.yaml</div> |
| 329 |
| 330 </div> <div class="col-md-5" markdown="1"> |
| 331 |
| 332 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 333 |
| 334 * A `pubspec.yaml` file in a directory identifies the directory |
| 335 and its contents as a package. |
| 336 |
| 337 * `pubspec.yaml` provides meta-data for the application, |
| 338 such as its name. |
| 339 |
| 340 * The `pubspec.yaml` file also lists the packages on which the app depends. |
| 341 The three packages needed by this app are all hosted on |
| 342 [pub.dartlang.org](https://pub.dartlang.org/). |
| 343 |
| 344 * `any` selects the latest version of the package that matches your SDK. |
| 345 |
| 346 </div></div> |
| 347 |
| 348 ### <i class="fa fa-anchor"> </i> Look at the packages directory |
| 349 |
| 350 <div class="row"> <div class="col-md-7"> |
| 351 |
| 352 <div class="trydart-step-details" markdown="1"> |
| 353 |
| 354 In Dart Editor, expand the top-level `packages` directory. |
| 355 |
| 356  |
| 357 |
| 358 </div> |
| 359 |
| 360 </div> <div class="col-md-5" markdown="1"> |
| 361 |
| 362 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 363 |
| 364 * The `packages` directory contains the code for all of the dependencies |
| 365 listed in the `pubspec.yaml` file. |
| 366 These are installed automatically by Dart Editor. |
| 367 |
| 368 * The `browser` package contains the `dart.js` script |
| 369 that checks for native Dart support. |
| 370 |
| 371 * The `http_server` package implements high-level HTTP server |
| 372 functionality, making it easier to write HTTP server code. |
| 373 |
| 374 * The `path` package provides common path manipulation operations, |
| 375 such as joining, splitting, and normalizing. |
| 376 |
| 377 * The `mime` package is included because `http_server` depends on it. |
| 378 |
| 379 * You're likely to see multiple `packages` directories. One is installed |
| 380 for every subdirectory that needs it. |
| 381 |
| 382 </div></div> |
| 383 |
| 384 ### <i class="fa fa-anchor"> </i> Run pub build |
| 385 |
| 386 <div class="row"> <div class="col-md-7"> |
| 387 |
| 388 <div class="trydart-step-details" markdown="1"> |
| 389 |
| 390 With `pubspec.yaml` still selected, |
| 391 select **Tools > Pub Build**. |
| 392 The output looks something like this: |
| 393 |
| 394 {% prettify bash %} |
| 395 --- Jan 16, 2014 4:14:36 PM Running pub build ... --- |
| 396 Building deploy_codelab..... |
| 397 [Info from Dart2JS]: |
| 398 Took 0:00:06.811770 to compile deploy_codelab|web/piratebadge.dart. |
| 399 Built 10 files! |
| 400 {% endprettify %} |
| 401 |
| 402 </div> |
| 403 |
| 404 <div class="trydart-filename">terminal</div> |
| 405 |
| 406 </div> <div class="col-md-5" markdown="1"> |
| 407 |
| 408 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 409 |
| 410 * The `pub build` command creates a `build` directory that contains |
| 411 everything your app needs to be deployed, including a minified |
| 412 JavaScript file and the required packages. |
| 413 |
| 414 </div></div> |
| 415 |
| 416 ### <i class="fa fa-anchor"> </i> Look at the `build` directory |
| 417 |
| 418 <div class="row"> <div class="col-md-7"> |
| 419 |
| 420 <div class="trydart-step-details" markdown="1"> |
| 421 |
| 422 The `pub build` command creates a `build` directory |
| 423 under `deploy-codelab`. |
| 424 |
| 425  |
| 426 </div> |
| 427 |
| 428 </div> <div class="col-md-5" markdown="1"> |
| 429 |
| 430 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 431 |
| 432 * The `piratebadge.dart.js` file is a JavaScript file that has been minified. |
| 433 When deployed, this file runs in the browser. |
| 434 |
| 435 * The `packages` directory contains the package dependencies. |
| 436 |
| 437 * Note that the `build` directory contains no `piratebadge.dart` file. |
| 438 It is not needed to deploy the app to JavaScript. |
| 439 |
| 440 </div></div> |
| 441 |
| 442 |
| 443 ### <i class="fa fa-anchor"> </i> Run the app as JavaScript |
| 444 |
| 445 <div class="row"> <div class="col-md-7"> |
| 446 |
| 447 <div class="trydart-step-details" markdown="1"> |
| 448 |
| 449 Open the app. |
| 450 Select **File > Open File...** |
| 451 in a browser such a Firefix or Safari |
| 452 and select the |
| 453 `deploy-codelab/build/piratebadge.html` file. |
| 454 |
| 455 </div> |
| 456 |
| 457 </div> <div class="col-md-5" markdown="1"> |
| 458 |
| 459 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 460 |
| 461 * The app is running on the local machine using the `file` protocol. |
| 462 To share your app with others, you need to deploy the app to a hosting service
, |
| 463 such as Heroku. |
| 464 |
| 465 </div></div> |
| 466 |
| 467 <hr> |
| 468 |
| 469 ##Step 3: Walk through the static file server's code {#step-three} |
| 470 |
| 471 You can build full HTTP servers with Dart. The HTTP libraries and packages |
| 472 support both serving static files and handling dynamic requests. For this code |
| 473 lab, we focus on serving static files. |
| 474 |
| 475 You need to provide a static file server for this project |
| 476 because Heroku requires one for deployment. |
| 477 Also, it's fun to serve your Dart client app with a server built with Dart! |
| 478 The code you downloaded for this project contains a static file server. |
| 479 This step walks through the code for the static file server, |
| 480 which uses some interesting Dart APIs and |
| 481 two helpful pub packages. |
| 482 |
| 483 Links to the relevant API docs are provided in [Resources](#resources). |
| 484 |
| 485 ### <i class="fa fa-anchor"> </i> Setting the path to the app. |
| 486 |
| 487 <div class="row"> <div class="col-md-7" markdown="1"> |
| 488 |
| 489 <div class="trydart-step-details" markdown="1"> |
| 490 |
| 491 Double click `bin/basic_http_server.dart` to open it. The beginning of |
| 492 the code is as follows: |
| 493 |
| 494 {% prettify dart %} |
| 495 import 'dart:io' show File, HttpServer, [[highlight]]Platform[[/highlight]]; |
| 496 import 'dart:async' show runZoned; |
| 497 import 'package:http_server/http_server.dart' show VirtualDirectory; |
| 498 import 'package:path/path.dart' show [[highlight]]join, dirname;[[/highlight]] |
| 499 |
| 500 void main() { |
| 501 [[highlight]]// Assumes the server lives in bin/ and that `pub build` ran.[[/h
ighlight]] |
| 502 [[highlight]]var pathToBuild = join(dirname(Platform.script.toFilePath()),[[/h
ighlight]] |
| 503 [[highlight]]'..', 'build');[[/highlight]] |
| 504 |
| 505 ... |
| 506 } |
| 507 {% endprettify %} |
| 508 </div> |
| 509 |
| 510 <div class="trydart-filename">basic_http_server.dart</div> |
| 511 |
| 512 </div> <div class="col-md-5" markdown="1"> |
| 513 |
| 514 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 515 |
| 516 * This code assumes that `pub build` has run, because |
| 517 it relies on the `build` directory existing. |
| 518 |
| 519 * In the next step, you will configure a Heroku buildpack |
| 520 (a collection of scripts) |
| 521 that runs `pub build` when you upload your app. |
| 522 |
| 523 * This code uses `join` along with `dirname` to |
| 524 create a path to the `build` directory |
| 525 based on the path of the running script. |
| 526 |
| 527 * The top-level `Platform` object provides information about the |
| 528 environment in which the program is running. |
| 529 Here, the code gets the filepath to the program. |
| 530 |
| 531 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 532 |
| 533 </div> </div> |
| 534 |
| 535 ### <i class="fa fa-anchor"> </i> Serving `piratebadge.html`. |
| 536 |
| 537 <div class="row"> <div class="col-md-7" markdown="1"> |
| 538 |
| 539 <div class="trydart-step-details" markdown="1"> |
| 540 |
| 541 {% prettify dart %} |
| 542 import 'dart:io' show [[highlight]]File[[/highlight]], HttpServer, Platform; |
| 543 import 'dart:async' show runZoned; |
| 544 import 'package:http_server/http_server.dart' show [[highlight]]VirtualDirectory
;[[/highlight]] |
| 545 import 'package:path/path.dart' show join, dirname; |
| 546 |
| 547 void main() { |
| 548 ... |
| 549 [[highlight]]var staticFiles = new VirtualDirectory(pathToBuild);[[/highlight]
] |
| 550 [[highlight]]staticFiles.allowDirectoryListing = true;[[/highlight]] |
| 551 [[highlight]]staticFiles.directoryHandler = (dir, request) {[[/highlight]] |
| 552 [[highlight]]// Redirect directory-requests to piratebadge.html file.[[/high
light]] |
| 553 [[highlight]]var indexUri = new Uri.file(dir.path).resolve('piratebadge.html
');[[/highlight]] |
| 554 [[highlight]]staticFiles.serveFile(new File(indexUri.toFilePath()), request)
;[[/highlight]] |
| 555 [[highlight]]};[[/highlight]] |
| 556 ... |
| 557 } |
| 558 {% endprettify %} |
| 559 </div> |
| 560 |
| 561 <div class="trydart-filename">basic_http_server.dart</div> |
| 562 |
| 563 </div> <div class="col-md-5" markdown="1"> |
| 564 |
| 565 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 566 |
| 567 * The `VirtualDirectory` class from the `http_server` package |
| 568 provides a high-level interface for serving static files and directory listing
s to HttpRequests. |
| 569 |
| 570 * This code redirects directory requests to `piratebadge.html`, |
| 571 which is the main HTML file for this app. |
| 572 This approach works because the deployed app has only one directory. |
| 573 |
| 574 * The `serveFile` method serves the requested static file |
| 575 to the given HttpRequest object. |
| 576 |
| 577 * Without the `http_server` package, this code would be longer and more complex, |
| 578 because you would have to use the lower-level `HttpServer`, `HttpRequest`, |
| 579 and `HttpResponse` APIs. |
| 580 |
| 581 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 582 |
| 583 </div> </div> |
| 584 |
| 585 ### <i class="fa fa-anchor"> </i> Using variable port numbers. |
| 586 |
| 587 <div class="row"> <div class="col-md-7" markdown="1"> |
| 588 |
| 589 <div class="trydart-step-details" markdown="1"> |
| 590 |
| 591 {% prettify %} |
| 592 import 'dart:io' show File, HttpServer, [[highlight]]Platform[[/highlight]]; |
| 593 import 'dart:async' show runZoned; |
| 594 import 'package:http_server/http_server.dart' show VirtualDirectory; |
| 595 import 'package:path/path.dart' show join, dirname; |
| 596 |
| 597 void main() { |
| 598 ... |
| 599 [[highlight]]var portEnv = Platform.environment['PORT'];[[/highlight]] |
| 600 [[highlight]]var port = portEnv == null ? 9999 : int.parse(portEnv);[[/highlig
ht]] |
| 601 ... |
| 602 } |
| 603 {% endprettify %} |
| 604 </div> |
| 605 |
| 606 <div class="trydart-filename">basic_http_server.dart</div> |
| 607 |
| 608 </div> <div class="col-md-5" markdown="1"> |
| 609 |
| 610 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 611 |
| 612 * Heroku uses variable ports. Heroku sets the `$PORT` environment variable |
| 613 with the port number that your app should listen to. |
| 614 |
| 615 * This code uses the port specified in the `$PORT` environment variable, |
| 616 if present. Otherwise, it uses port 9999. |
| 617 |
| 618 * The `$PORT` environment variable might not be present if the web server is run
ning |
| 619 in a non-Heroku environment. |
| 620 |
| 621 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 622 |
| 623 </div> </div> |
| 624 |
| 625 |
| 626 ### <i class="fa fa-anchor"> </i> Using `runZoned()`. |
| 627 |
| 628 <div class="row"> <div class="col-md-7" markdown="1"> |
| 629 |
| 630 <div class="trydart-step-details" markdown="1"> |
| 631 |
| 632 |
| 633 {% prettify dart %} |
| 634 import 'dart:io' show File, HttpServer, Platform; |
| 635 import 'dart:async' show [[highlight]]runZoned[[/highlight]]; |
| 636 import 'package:http_server/http_server.dart' show VirtualDirectory; |
| 637 import 'package:path/path.dart' show join, dirname; |
| 638 |
| 639 void main() { |
| 640 ... |
| 641 [[highlight]]runZoned(() {[[/highlight]] |
| 642 ... |
| 643 [[highlight]]},[[/highlight]] |
| 644 [[highlight]]onError: (e, stackTrace) => print('Oh noes! $e $stackTrace'));[[/
highlight]] |
| 645 } |
| 646 {% endprettify %} |
| 647 </div> |
| 648 |
| 649 <div class="trydart-filename">basic_http_server.dart</div> |
| 650 |
| 651 </div> <div class="col-md-5" markdown="1"> |
| 652 |
| 653 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 654 |
| 655 * `runZoned` helps provide stability to your program. |
| 656 It catches exceptions from all call stacks within its bounds, |
| 657 allowing your program to continue running in spite of errors. |
| 658 |
| 659 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 660 |
| 661 </div> </div> |
| 662 |
| 663 ### <i class="fa fa-anchor"> </i> Listening for HTTP requests. |
| 664 |
| 665 <div class="row"> <div class="col-md-7" markdown="1"> |
| 666 |
| 667 <div class="trydart-step-details" markdown="1"> |
| 668 |
| 669 |
| 670 {% prettify dart %} |
| 671 import 'dart:io' show File, [[highlight]]HttpServer[[/highlight]], Platform; |
| 672 import 'dart:async' show runZoned; |
| 673 import 'package:http_server/http_server.dart' show VirtualDirectory; |
| 674 import 'package:path/path.dart' show join, dirname; |
| 675 |
| 676 void main() { |
| 677 ... |
| 678 runZoned(() { |
| 679 [[highlight]]HttpServer.bind('0.0.0.0', port).then((server) {[[/highlight]] |
| 680 [[highlight]]server.listen(staticFiles.serveRequest);[[/highlight]] |
| 681 [[highlight]]});[[/highlight]] |
| 682 }, |
| 683 onError: (e, stackTrace) => print('Oh noes! $e $stackTrace')); |
| 684 } |
| 685 {% endprettify %} |
| 686 </div> |
| 687 |
| 688 <div class="trydart-filename">basic_http_server.dart</div> |
| 689 |
| 690 </div> <div class="col-md-5" markdown="1"> |
| 691 |
| 692 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 693 |
| 694 * `HttpServer.bind()` creates an HTTP server, which responds to HTTP requests |
| 695 for this app. |
| 696 |
| 697 * The HTTP server binds to a host `0.0.0.0`. |
| 698 which is a special address that is guaranteed |
| 699 to receive requests from any network socket. |
| 700 If you don't know what specific IP to listen to, you can use 0.0.0.0. |
| 701 |
| 702 * The HTTP server listens for requests and uses the `VirtualDirectory` object |
| 703 named `staticFiles` to handle them. |
| 704 |
| 705 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 706 |
| 707 </div> </div> |
| 708 |
| 709 |
| 710 ### <i class="fa fa-anchor"> </i> Run the web server, run the app |
| 711 |
| 712 <div class="row"> <div class="col-md-7" markdown="1"> |
| 713 |
| 714 <div class="trydart-step-details" markdown="1"> |
| 715 |
| 716 In Dart Editor, |
| 717 right click `bin/basic_http_server.dart` and select `Run`. |
| 718 Dart Editor brings up a new output pane in which the web server |
| 719 displays its output, if any. |
| 720 |
| 721 Now, open `0.0.0.0:9999` in your browser. |
| 722 The app appears and you can generate pirate names. |
| 723 |
| 724 <strong>Leave the web server running.</strong> |
| 725 |
| 726 </div> |
| 727 |
| 728 |
| 729 </div> <div class="col-md-5" markdown="1"> |
| 730 |
| 731 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 732 |
| 733 * 0.0.0.0:9999 requests the root directory of that host and port. |
| 734 The static file server resolves that request to `piratebadge.html` |
| 735 and returns the contents of that file. |
| 736 |
| 737 * 0.0.0.0:9999 requests work only on your local machine. |
| 738 Another machine cannot run your app using that URL. |
| 739 In [Step 5](#step-five), you deploy your app to Heroku, |
| 740 which gives you a public URL. |
| 741 |
| 742 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 743 |
| 744 </div> </div> |
| 745 |
| 746 <hr> |
| 747 |
| 748 ##Step 4: Inspect your app on a mobile device {#step-four} |
| 749 |
| 750 Before deploying your app, |
| 751 you can use the Chrome DevTools to check, debug, and modify |
| 752 your app on a mobile device. |
| 753 DevTools can debug Android devices natively |
| 754 and other devices using |
| 755 [Mobile Emulation](https://developers.google.com/chrome-developer-tools/docs/mob
ile-emulation). |
| 756 This section shows you how to use DevTools with your app on an Android device. |
| 757 |
| 758 You don't need to do this step to deploy your app. |
| 759 You can skip and move on to [Step 5](#step-five). |
| 760 However, this does help you to test and debug your app on mobile devices |
| 761 and it's pretty cool. |
| 762 |
| 763 ### <i class="fa fa-anchor"> </i> Set up your computer and device |
| 764 |
| 765 <div class="trydart-step-details" markdown="1"> |
| 766 |
| 767 Follow the instructions at |
| 768 [Remote Debugging Chrome on Android](https://developers.google.com/chrome-develo
per-tools/docs/remote-debugging) |
| 769 to set up your device, Chrome, and your computer. |
| 770 |
| 771 </div> |
| 772 |
| 773 ### <i class="fa fa-anchor"> </i> Run the app on your mobile device |
| 774 |
| 775 <div class="trydart-step-details" markdown="1"> |
| 776 |
| 777 Make sure your web server is still running from [Step 3](#step-three). |
| 778 |
| 779 On your mobile device, bring up Chrome, |
| 780 and open `0.0.0.0:9999` in your browser. |
| 781 |
| 782 <img src="images/calebthebrave.png" height="400"> |
| 783 |
| 784 </div> |
| 785 |
| 786 ### <i class="fa fa-anchor"> </i> Bring up Devices page |
| 787 |
| 788 <div class="trydart-step-details" markdown="1"> |
| 789 |
| 790 In Chrome on your computer, |
| 791 click the Android icon at the right side of any window |
| 792 and select **View Inspection Targets**. |
| 793 If the Android icon is not there, |
| 794 then the mobile device or your computer is not properly connected or setup. |
| 795 Refer back to the |
| 796 [Remote Debugging Chrome on Android](https://developers.google.com/chrome-develo
per-tools/docs/remote-debugging) |
| 797 instructions. |
| 798 |
| 799  |
| 800 |
| 801 The Devices page appears and an entry for your app appears. |
| 802 Note the green dots. Make sure that one of them has the label `:9999`. |
| 803 If not, you need to click the **Port forwarding...** button |
| 804 and turn on port forwarding for `0.0.0.0:9999`. |
| 805 |
| 806  |
| 807 |
| 808 |
| 809 </div> |
| 810 |
| 811 ### <i class="fa fa-anchor"> </i> Bring up DevTools for the app |
| 812 |
| 813 <div class="trydart-step-details" markdown="1"> |
| 814 |
| 815 On the Devices page, click `inspect` under the entry for your app. |
| 816 A DevTools window appears that is attached to your app running |
| 817 on the mobile device. |
| 818 You are now inspecting the client app running on your mobile device. |
| 819 |
| 820  |
| 821 |
| 822 </div> |
| 823 |
| 824 ### <i class="fa fa-anchor"> </i> Experiment with changing the app |
| 825 |
| 826 <div class="trydart-step-details" markdown="1"> |
| 827 |
| 828 Experiment by using DevTools to modify the font size or color. |
| 829 The change happens instantly on your mobile device. |
| 830 |
| 831 </div> |
| 832 |
| 833 |
| 834 ##Step 5: Deploy to Heroku {#step-five} |
| 835 |
| 836 In this step, you deploy your web server and app to Heroku. |
| 837 Heroku is a cloud hosting service that has |
| 838 a free tier and can run arbitrary VMs, |
| 839 which is why we're using it here. |
| 840 |
| 841 ### <i class="fa fa-anchor"> </i> Get Heroku and a Heroku account |
| 842 |
| 843 <div class="row"> <div class="col-md-7" markdown="1"> |
| 844 |
| 845 <div class="trydart-step-details" markdown="1"> |
| 846 |
| 847 Follow Steps 1, 2, and 3 at |
| 848 [Getting Started with Heroku](https://devcenter.heroku.com/articles/quickstart) |
| 849 to download the Heroku tools and get an account with Heroku. |
| 850 |
| 851 </div> |
| 852 |
| 853 </div> <div class="col-md-5" markdown="1"> |
| 854 |
| 855 |
| 856 </div> </div> |
| 857 |
| 858 |
| 859 ### <i class="fa fa-anchor"> </i> Create a `Procfile` |
| 860 |
| 861 <div class="row"> <div class="col-md-7" markdown="1"> |
| 862 |
| 863 <div class="trydart-step-details" markdown="1"> |
| 864 |
| 865 In the `deploy-codelab` directory, create a file |
| 866 named `Procfile` and add the following line to it. |
| 867 |
| 868 {% prettify bash %} |
| 869 |
| 870 web: ./dart-sdk/bin/dart bin/basic_http_server.dart |
| 871 |
| 872 {% endprettify %} |
| 873 |
| 874 </div> |
| 875 |
| 876 <div class="trydart-filename">Procfile</div> |
| 877 |
| 878 </div> <div class="col-md-5" markdown="1"> |
| 879 |
| 880 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 881 |
| 882 * A `Procfile` tells Heroku what part of your app can be executed. |
| 883 |
| 884 * The `Procfile` for this example defines a web process type |
| 885 in which the dart VM runs the static file server. |
| 886 |
| 887 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 888 |
| 889 </div> </div> |
| 890 |
| 891 |
| 892 ### <i class="fa fa-anchor"> </i> Commit your changes to your local `deploy-code
lab` git repo |
| 893 |
| 894 <div class="trydart-step-details" markdown="1"> |
| 895 |
| 896 `git` is a software configuration management system |
| 897 and the means for deploying apps to Heroku. |
| 898 If you don't already have `git`, you need to download it. |
| 899 Refer to |
| 900 [Pro Git book](http://git-scm.com/downloads). |
| 901 for downloads and documentation. |
| 902 |
| 903 Before you can push an app to Heroku, |
| 904 you need to initialize a local `git` repo and commit your files to it. |
| 905 </div> |
| 906 |
| 907 <div class="row"> <div class="col-md-7" markdown="1"> |
| 908 |
| 909 <div class="trydart-step-details" markdown="1"> |
| 910 |
| 911 {% prettify bash %} |
| 912 $ cd deploy-codelab |
| 913 $ git init |
| 914 $ git add -A . |
| 915 $ git commit -am "Hoist the mizzen!" |
| 916 $ |
| 917 {% endprettify %} |
| 918 |
| 919 </div> |
| 920 |
| 921 <div class="trydart-filename">terminal</div> |
| 922 |
| 923 </div> <div class="col-md-5" markdown="1"> |
| 924 |
| 925 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 926 |
| 927 * With `git init` you create a local repo. |
| 928 |
| 929 * Next, `git add` adds the specified files to the local repo. |
| 930 |
| 931 * Finally, `git commit` saves the files to your local git repo. |
| 932 |
| 933 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 934 |
| 935 </div> </div> |
| 936 |
| 937 ### <i class="fa fa-anchor"> </i> Create a Heroku app and configure it. |
| 938 |
| 939 <div class="row"> <div class="col-md-7" markdown="1"> |
| 940 |
| 941 <div class="trydart-step-details" markdown="1"> |
| 942 |
| 943 <strong>Important:</strong> Replace |
| 944 `myfirstdartappforheroku` with something **unique**. |
| 945 |
| 946 {% prettify bash %} |
| 947 $ heroku create [[highlight]]myfirstdartappforheroku[[/highlight]] -s cedar |
| 948 $ heroku labs:enable user-env-compile |
| 949 $ heroku config:set DART_SDK_URL=https://github.com/selkhateeb/heroku-vagrant-da
rt-build/releases/download/latest/dart-sdk.tar |
| 950 $ heroku config:add BUILDPACK_URL=https://github.com/igrigorik/heroku-buildpack-
dart.git |
| 951 $ |
| 952 {% endprettify %} |
| 953 |
| 954 </div> |
| 955 |
| 956 <div class="trydart-filename">terminal</div> |
| 957 |
| 958 </div> <div class="col-md-5" markdown="1"> |
| 959 |
| 960 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 961 |
| 962 * With the first command, `heroku create`, you create a Heroku app |
| 963 with the specified name. |
| 964 Provide it with a **unique** name (not `myfirstdartappforheroku`). |
| 965 |
| 966 * Enabling `user-env-compile` allows environment variables |
| 967 to be passed to the build script during deploy. |
| 968 |
| 969 * Official builds of Dart do not support Heroku due to mismatched glibc versions
. |
| 970 The `DART_SDK_URL` specifies |
| 971 the (unsupported) [Vagrant Dart Build](https://github.com/selkhateeb/heroku-va
grant-dart-build), |
| 972 which is a special build of the Dart SDK that is compatible with Heroku. |
| 973 |
| 974 * A buildpack extends Heroku. The buildpack used here extends Heroku |
| 975 to support Dart apps. The location of the buildpack |
| 976 is specified with the `BUILDPACK_URL`. |
| 977 |
| 978 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 979 |
| 980 </div> </div> |
| 981 |
| 982 ### <i class="fa fa-anchor"> </i> Push your app to Heroku |
| 983 |
| 984 <div class="row"> <div class="col-md-7" markdown="1"> |
| 985 |
| 986 <div class="trydart-step-details" markdown="1"> |
| 987 |
| 988 Type the `git push` command as shown. |
| 989 Some output has been replaced with ellipses to save space, |
| 990 but the output from the push command will look something this: |
| 991 |
| 992 |
| 993 {% prettify bash %} |
| 994 $ [[highlight]]git push heroku master[[/highlight]] |
| 995 Initializing repository, done. |
| 996 |
| 997 ... |
| 998 -----> Fetching custom git buildpack... done |
| 999 -----> Dart app detected |
| 1000 ... |
| 1001 Dart VM version: 1.0.0.5_r30248_vagrant (Thu Nov 14 13:43:29 2013) on "linux_x64
" |
| 1002 ... |
| 1003 *** Running pub build |
| 1004 Building with "pub build" |
| 1005 Building deploy_codelab.................... |
| 1006 [Info in Dart2JS]: |
| 1007 Generated deploy_codelab|web/piratebadge.dart.js (97701 characters) in 0:01:19.6
85114 |
| 1008 Built 6 files! |
| 1009 ... |
| 1010 -----> Launching... done, v6 |
| 1011 [[highlight]]http://myfirstdartappforheroku.herokuapp.com deployed to Her
oku[[/highlight]] |
| 1012 |
| 1013 To git@heroku.com:myfirstdartappforheroku.git |
| 1014 * [new branch] master -> master |
| 1015 $ |
| 1016 {% endprettify %} |
| 1017 |
| 1018 |
| 1019 </div> |
| 1020 |
| 1021 <div class="trydart-filename">terminal</div> |
| 1022 |
| 1023 </div> <div class="col-md-5" markdown="1"> |
| 1024 |
| 1025 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 1026 |
| 1027 |
| 1028 * Your local `git` repository becomes associated with a remote Heroku repository
, |
| 1029 usually named `heroku`, when you push. |
| 1030 |
| 1031 * When you push, Heroku runs the buildpack that you specified. |
| 1032 |
| 1033 * In addition to other tasks, this buildpack runs `pub build`. |
| 1034 |
| 1035 * When the push is finished, the process displays a URL for your app. |
| 1036 |
| 1037 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 1038 |
| 1039 </div> </div> |
| 1040 |
| 1041 ### <i class="fa fa-anchor"> </i> Specify the scale |
| 1042 |
| 1043 <div class="row"> <div class="col-md-7" markdown="1"> |
| 1044 |
| 1045 <div class="trydart-step-details" markdown="1"> |
| 1046 |
| 1047 {% prettify bash %} |
| 1048 $ heroku ps:scale web=1 |
| 1049 $ |
| 1050 {% endprettify %} |
| 1051 |
| 1052 </div> |
| 1053 |
| 1054 <div class="trydart-filename">terminal</div> |
| 1055 |
| 1056 </div> <div class="col-md-5" markdown="1"> |
| 1057 |
| 1058 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 1059 |
| 1060 * Scale to one _dyno_, which is a Heroku lightweight container |
| 1061 that runs a single user-specified command. |
| 1062 |
| 1063 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 1064 |
| 1065 </div> </div> |
| 1066 |
| 1067 <hr> |
| 1068 |
| 1069 ##Step 6: Run the app on the web and on a mobile device {#step-six} |
| 1070 |
| 1071 Now that your app is deployed, you can run it on the web |
| 1072 and on a mobile device. |
| 1073 |
| 1074 ### <i class="fa fa-anchor"> </i> Run the app in a browser |
| 1075 |
| 1076 <div class="row"> <div class="col-md-7" markdown="1"> |
| 1077 |
| 1078 <iframe class="running-app-frame" |
| 1079 style="height:220px;width:550px;" |
| 1080 src="/codelabs/darrrt/examples/6-piratebadge/piratebadge.html"> |
| 1081 </iframe> |
| 1082 |
| 1083 |
| 1084 </div> <div class="col-md-5" markdown="1"> |
| 1085 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 1086 |
| 1087 * Use the URL displayed by the previous step to visit your app: |
| 1088 `http://myfirstdartappforheroku.herokuapp.com` |
| 1089 |
| 1090 </div> </div> |
| 1091 |
| 1092 |
| 1093 ### <i class="fa fa-anchor"> </i> Run the app on a mobile device |
| 1094 |
| 1095 <div class="row"> <div class="col-md-7" markdown="1"> |
| 1096 |
| 1097 <div class="trydart-step-details" markdown="1"> |
| 1098 |
| 1099 <img src="images/calebthebrave.png" height="400"> |
| 1100 |
| 1101 </div> |
| 1102 |
| 1103 </div> <div class="col-md-5" markdown="1"> |
| 1104 |
| 1105 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 1106 |
| 1107 * Use the URL from the previous step to load the app |
| 1108 into a browser on your mobile device. |
| 1109 `http://myfirstdartappforheroku.herokuapp.com` |
| 1110 |
| 1111 {% comment %} non-breaking space required for bootstrap/markdown bogosity
{% endcomment %} |
| 1112 |
| 1113 </div> </div> |
| 1114 |
| 1115 |
| 1116 |
| 1117 <div class="trydart-step-details" markdown="1"> |
| 1118 </div> |
| 1119 |
| 1120 <hr> |
| 1121 |
| 1122 ##What next? {#what-next} |
| 1123 |
| 1124 Now that your app is deployed for the world to use, |
| 1125 what do you do now? |
| 1126 Here are some suggestions. |
| 1127 |
| 1128 ### <i class="fa fa-anchor"> </i> Share your app with the world! |
| 1129 |
| 1130 <div class="trydart-step-details" markdown="1"> |
| 1131 |
| 1132 Share your Heroku URL with your followers and circles. |
| 1133 |
| 1134 * <a href="https://twitter.com/share" class="twitter-share-button" data-text="Ar
rr! I've deployed me app. http://dartlang.org/codelab/deploy/" data-count="none"
data-hashtags="dartlang">Tweet</a> |
| 1135 <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.tes
t(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.
id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(
js,fjs);}}(document, 'script', 'twitter-wjs');</script> |
| 1136 |
| 1137 {% comment %} |
| 1138 * <p class="share-button twitter"> |
| 1139 <a href="https://twitter.com/share" |
| 1140 class="twitter-share-button external-link" |
| 1141 data-count="none" |
| 1142 data-text="Arrr! I've deployed me app. http://dartlang.org/codelab/deploy/" |
| 1143 data-hashtags="dartlang">Tweet</a> </p> |
| 1144 {% endcomment %} |
| 1145 |
| 1146 * <p> |
| 1147 <script src="https://apis.google.com/js/plusone.js"></script> |
| 1148 <g:plus action="share"></g:plus> </p> |
| 1149 |
| 1150 </div> |
| 1151 |
| 1152 ### <i class="fa fa-anchor"> </i> Jump to another ship. |
| 1153 |
| 1154 <div class="trydart-step-details" markdown="1"> |
| 1155 |
| 1156 * If you never went through the [Avast, Ye Pirates](/codelabs/darrrt/) code lab,
do it now. |
| 1157 * For more command-line application and server code, |
| 1158 visit [Dart by Example](/dart-by-example/). |
| 1159 * Play with some [samples](/samples/). |
| 1160 * Try the [tutorials](/docs/tutorials/), |
| 1161 in particular the [command-line app tutorial](/docs/tutorials/cmdline/). |
| 1162 * Go write some awesome code. |
| 1163 |
| 1164 |
| 1165 ##Resources {#resources} |
| 1166 |
| 1167 For more information about the tools and libraries used |
| 1168 in this code lab, check out these resources. |
| 1169 |
| 1170 <div class="trydart-step-details" markdown="1"> |
| 1171 |
| 1172 #### SDK libraries, classes, and functions |
| 1173 |
| 1174 * The API docs for the |
| 1175 <a href="https://api.dartlang.org/dart_io/File.html" target="_blank">File</a>, |
| 1176 <a href="https://api.dartlang.org/dart_io/HttpServer.html" target="_blank">HttpS
erver</a>, and |
| 1177 <a href="https://api.dartlang.org/dart_io/Platform.html" target="_blank">Platfor
m</a> |
| 1178 classes from the |
| 1179 <a href="https://api.dartlang.org/dart_io.html" target="_blank">dart:io</a> |
| 1180 library. |
| 1181 * The API docs for the |
| 1182 <a href="https://api.dartlang.org/dart_async.html#runZoned" target="_blank">runZ
oned()</a> |
| 1183 function from the |
| 1184 <a href="https://api.dartlang.org/dart_async.html" target="_blank">dart:async</a
> library. |
| 1185 |
| 1186 #### Classes and functions from pub packages |
| 1187 |
| 1188 * The code for the |
| 1189 <a href="https://pub.dartlang.org/packages/http_server">http_server</a> pub pack
age, |
| 1190 in particular |
| 1191 <a href="https://api.dartlang.org/http_server/VirtualDirectory.html" target="_bl
ank">VirtualDirectory</a> |
| 1192 class. |
| 1193 * The code for the |
| 1194 <a href="http://pub.dartlang.org/packages/path">path</a> pub package, |
| 1195 in particular the |
| 1196 <a href="https://api.dartlang.org/path.html#join" target="_blank">join()</a> |
| 1197 and |
| 1198 <a href="https://api.dartlang.org/path.html#dirname" target="_blank">dirname()</
a> |
| 1199 functions. |
| 1200 |
| 1201 #### Heroku tools |
| 1202 |
| 1203 * The <a href="https://devcenter.heroku.com/">Heroku Dev Center</a>. |
| 1204 * The Heroku-compatible build of the Dart SDK: |
| 1205 [heroku-vagrant-dart-build](https://github.com/selkhateeb/heroku-vagrant-dart-bu
ild). |
| 1206 * The Heroku buildpack for Dart: |
| 1207 [heroku-buildpack-dart](https://github.com/igrigorik/heroku-buildpack-dart). |
| 1208 |
| 1209 #### The example code |
| 1210 |
| 1211 * The [deploy-codelab](https://github.com/dart-lang/deploy-codelab) |
| 1212 example code. |
| 1213 |
| 1214 </div> |
| 1215 |
| 1216 <hr> |
| 1217 |
| 1218 </div> |
| 1219 |
| OLD | NEW |