do2server

A library for Dart developers.

Usage

A simple usage example:

import 'package:do2server/do2server.dart';
import 'dart:io';
import 'package:path/path.dart';
import 'package:route/server.dart';
import 'package:route/pattern.dart';
import 'package:http_server/http_server.dart';

main() {
  Do2Server server = new Do2Server()
      ..addServer(HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 4040))
      ..start();
      
  VirtualDirectory staticFiles = new VirtualDirectory(dirname(Platform.script.toFilePath()) + '/www/');
  staticFiles.allowDirectoryListing = true;
  staticFiles.directoryHandler = (dir, request) {
    var indexUri = new Uri.file(dir.path).resolve('index.html');
    staticFiles.serveFile(new File(indexUri.toFilePath()), request);
  };

  Router router = server.addHost('*');
  staticFiles.serve(router.defaultStream);
}

Features and bugs

Please file feature requests and bugs at the issue tracker.

Libraries

do2server