Chapter 13. Server interaction with files and HTTP

 

This chapter covers

  • Running Dart scripts from the command line
  • Interacting with the filesystem
  • Serving content via HTTP

The Dart virtual machine is hosted in two different environments. In the previous part of the book, we looked at using Dart in the web browser, where the VM is embedded in the Dartium web browser and has access to the browser DOM via the dart:html library. In this chapter, we’ll start to explore the server-side Dart VM, which doesn’t have access to the browser DOM but instead has access to operating system I/O, such as files and network sockets via the dart:io library.

The Dart File Browser example project scenario for this chapter has a client-and-server solution that provides a browser-based text editor for editing Dart files, which we’ll tackle in three steps starting with the server side. The server-side Dart VM is hosted in a command-line executable, available for Windows, Mac, and Linux. We’ll begin by looking at how you can write a simple Dart script that interacts with the filesystem, passing command-line arguments to output a directory listing.

Next, we’ll look at serving HTTP to react to HTTP requests from a web browser. We’ll show you how to match URL request paths and serve static files from a server-side Dart application. This gives you the ability to develop a complete client-and-server solution in Dart.

13.1. Running server-side Dart scripts

 
 
 

13.2. Serving browser HTTP requests

 

13.3. Serving clients with a RESTful API

 
 
 

13.4. Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage