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