angel_static 2.0.2 copy "angel_static: ^2.0.2" to clipboard
angel_static: ^2.0.2 copied to clipboard

outdated

Static server middleware for Angel. Use this to serve files to users.

example/main.dart

import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';
import 'package:angel_static/angel_static.dart';
import 'package:file/local.dart';
import 'package:logging/logging.dart';

main() async {
  var app = new Angel();
  var http = new AngelHttp(app);
  var fs = const LocalFileSystem();
  var vDir = new CachingVirtualDirectory(app, fs,
      allowDirectoryListing: true,
      source: fs.currentDirectory,
      maxAge: const Duration(days: 24).inSeconds);

  app.mimeTypeResolver
    ..addExtension('', 'text/plain')
    ..addExtension('dart', 'text/dart')
    ..addExtension('lock', 'text/plain')
    ..addExtension('markdown', 'text/plain')
    ..addExtension('md', 'text/plain')
    ..addExtension('yaml', 'text/plain');

  app.logger = new Logger('example')
    ..onRecord.listen((rec) {
      print(rec);
      if (rec.error != null) print(rec.error);
      if (rec.stackTrace != null) print(rec.stackTrace);
    });

  app.fallback(vDir.handleRequest);

  var server = await http.startServer('127.0.0.1', 3000);
  print('Listening at http://${server.address.address}:${server.port}');
}
2
likes
0
pub points
25%
popularity

Publisher

verified publisherangel-dart.dev

Static server middleware for Angel. Use this to serve files to users.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

angel_framework, file, http_parser, path

More

Packages that depend on angel_static