2024-10-13 01:45:27 +00:00
|
|
|
import 'package:protevus_framework/protevus_framework.dart';
|
|
|
|
import 'package:protevus_framework/http.dart';
|
|
|
|
import 'package:protevus_html/protevus_html.dart';
|
2021-09-11 04:03:14 +00:00
|
|
|
import 'package:belatuk_html_builder/elements.dart';
|
2019-01-06 18:11:11 +00:00
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
|
2021-06-20 12:37:20 +00:00
|
|
|
void main() async {
|
2024-10-12 10:35:14 +00:00
|
|
|
var app = Protevus();
|
|
|
|
var http = ProtevusHttp(app);
|
2019-01-06 18:11:11 +00:00
|
|
|
app.logger = Logger('angel_html')
|
|
|
|
..onRecord.listen((rec) {
|
|
|
|
print(rec);
|
|
|
|
if (rec.error != null) print(rec.error);
|
|
|
|
if (rec.stackTrace != null) print(rec.stackTrace);
|
|
|
|
});
|
|
|
|
|
|
|
|
app.fallback(renderHtml());
|
|
|
|
|
|
|
|
app.get('/html', (req, res) {
|
|
|
|
return html(c: [
|
|
|
|
head(c: [
|
|
|
|
title(c: [text('ok')])
|
|
|
|
])
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get(
|
|
|
|
'/strict',
|
|
|
|
chain([
|
|
|
|
renderHtml(
|
|
|
|
enforceAcceptHeader: true,
|
|
|
|
renderer: StringRenderer(
|
2021-06-20 12:37:20 +00:00
|
|
|
//doctype: null,
|
2019-01-06 18:11:11 +00:00
|
|
|
pretty: false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(req, res) {
|
|
|
|
return div(c: [text('strict')]);
|
|
|
|
},
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
|
2024-10-12 10:35:14 +00:00
|
|
|
app.fallback((req, res) => throw ProtevusHttpException.notFound());
|
2019-01-06 18:11:11 +00:00
|
|
|
|
|
|
|
await http.startServer('127.0.0.1', 3000);
|
|
|
|
print('Listening at ${http.uri}');
|
|
|
|
}
|