Skip to content
jorishermans edited this page Nov 23, 2014 · 1 revision

Dart Force is available as a package at pub. So, all you have to do is add it as a dependency to your app.

Step one

Create a new Dart project, manually, with stagehand or with the dart editor.

Step two

Add Force as a dependency in pubspec.yaml file:

name: my_app
dependencies:
   force: any

Run 'pub get' to update dependencies

Step three

Create a bin directory Create a server.dart file under the bin directory

import "package:force/force_serverside.dart";

ForceServer fs = new ForceServer();

main() {
  fs.server.use("/", (req, model) => "index");

  fs.start();
}

Step 4

Now in the web folder you need to create a index.html page. This page will be served when you go to "/". Dart Force uses the mustache template engine {{}}, so when you plan to use angular or polymer, you need to change the delimiter.

Final Step

To run the server, create a launch configuration in Dart Editor, or use the dart command:

 $ dart bin/server.dart
 INFO: 2014-11-22 21:52:08.598: Web server is running on 'http://localhost:8080/'

Go visit http://127.0.0.1:8080/ in your browser, and you should see your index page.

Clone this wiki locally