Still needs work

This commit is contained in:
Tobe O 2017-10-01 01:00:14 -04:00
parent 14db5f99c5
commit 72844bf6c8
3 changed files with 18 additions and 6 deletions

View file

@ -4,14 +4,22 @@ import 'package:file/local.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
main() async { main() async {
var app = new Angel(); var app = new Angel()..lazyParseBodies = true;
var fileSystem = const LocalFileSystem(); var fileSystem = const LocalFileSystem();
await app.configure( await app.configure(
jael(fileSystem.directory('views')), jael(fileSystem.directory('views')),
); );
app.get('/', (res) => res.render('index', {'title': 'ESKETTIT'})); app.get('/',
(res) => res.render('index', {'title': 'Sample App', 'message': null}));
app.post('/', (RequestContext req, res) async {
var body = await req.lazyBody();
var msg = body['message'] ?? '<unknown>';
return await res
.render('index', {'title': 'Form Submission', 'message': msg});
});
app.use(() => throw new AngelHttpException.notFound()); app.use(() => throw new AngelHttpException.notFound());

View file

@ -1,5 +1,12 @@
<extend src="layout.jl"> <extend src="layout.jl">
<block name="content"> <block name="content">
Hello, world!!! <i if=message != null>
You said: {{ message }}
</i>
<form action="/" method="post">
<input name="message" placeholder="Say something..." type="text" value=message>
<br>
<input type="submit" value="Submit">
</form>
</block> </block>
</extend> </extend>

View file

@ -12,8 +12,5 @@
<block name="content"> <block name="content">
<i>Content goes here.</i> <i>Content goes here.</i>
</block> </block>
<script>
window.alert("a");
</script>
</body> </body>
</html> </html>