2019-05-01 04:29:21 +00:00
|
|
|
import 'dart:io';
|
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';
|
2019-09-29 04:20:42 +00:00
|
|
|
import 'package:pretty_logging/pretty_logging.dart';
|
2018-07-03 23:16:29 +00:00
|
|
|
|
|
|
|
main() async {
|
2019-09-29 04:30:52 +00:00
|
|
|
hierarchicalLoggingEnabled = true;
|
|
|
|
|
|
|
|
var logger = Logger.detached('wings')
|
|
|
|
..level = Level.ALL
|
|
|
|
..onRecord.listen(prettyLog);
|
|
|
|
var app = Angel(logger: logger);
|
2019-03-14 17:24:31 +00:00
|
|
|
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);
|
2019-04-30 17:40:11 +00:00
|
|
|
|
|
|
|
app.mimeTypeResolver.addExtension('yaml', 'text/x-yaml');
|
2019-04-29 08:22:36 +00:00
|
|
|
|
|
|
|
app.get('/', (req, res) => 'WINGS!!!');
|
2019-05-01 04:29:21 +00:00
|
|
|
app.post('/', (req, res) async {
|
|
|
|
await req.parseBody();
|
|
|
|
return req.bodyAsMap;
|
|
|
|
});
|
2019-09-29 04:30:52 +00:00
|
|
|
|
2019-04-29 08:22:36 +00:00
|
|
|
app.fallback(vDir.handleRequest);
|
|
|
|
app.fallback((req, res) => throw AngelHttpException.notFound());
|
|
|
|
|
2019-09-29 04:30:52 +00:00
|
|
|
await wings.startServer(InternetAddress.loopbackIPv4, 3000);
|
2019-04-30 17:40:11 +00:00
|
|
|
print('Listening at ${wings.uri}');
|
2019-04-29 08:22:36 +00:00
|
|
|
}
|