platform/example/main.dart

27 lines
866 B
Dart
Raw Normal View History

2018-07-03 23:16:29 +00:00
import 'package:angel_framework/angel_framework.dart';
2019-04-29 08:22:36 +00:00
import 'package:angel_static/angel_static.dart';
2018-07-03 23:16:29 +00:00
import 'package:angel_wings/angel_wings.dart';
2019-04-29 08:22:36 +00:00
import 'package:file/local.dart';
import 'package:logging/logging.dart';
2018-07-03 23:16:29 +00:00
main() async {
var app = Angel();
var wings = AngelWings(app);
2019-04-29 08:22:36 +00:00
var fs = LocalFileSystem();
var vDir = CachingVirtualDirectory(app, fs,
source: fs.currentDirectory, allowDirectoryListing: true);
app.logger = Logger('wings')
..onRecord.listen((rec) {
print(rec);
if (rec.error != null) print(rec.error);
if (rec.stackTrace != null) print(rec.stackTrace);
});
app.get('/', (req, res) => 'WINGS!!!');
app.fallback(vDir.handleRequest);
app.fallback((req, res) => throw AngelHttpException.notFound());
await wings.startServer('127.0.0.1', 3000);
print('Listening at http://localhost:3000');
}