platform/example/main.dart

22 lines
588 B
Dart
Raw Normal View History

2018-02-07 04:38:26 +00:00
import 'package:angel_framework/angel_framework.dart';
main() async {
var app = new Angel();
app.get('/', () => 'Welcome to Angel!');
app.get('/greet/:name', (String name) => 'Hello, $name!');
2018-04-06 19:45:58 +00:00
app.get('/greet', (@Session('name') String name) => 'Hello, $name!');
2018-02-07 04:38:26 +00:00
app.use((RequestContext req) async {
throw new AngelHttpException.notFound(
message: 'Unknown path: "${req.uri.path}"',
);
});
var http = new AngelHttp(app);
var server = await http.startServer('127.0.0.1', 3000);
print('Listening at http://${server.address.address}:${server.port}');
}