Book Image

Dart By Example

By : David Mitchell
Book Image

Dart By Example

By: David Mitchell

Overview of this book

Table of Contents (17 chapters)
Dart By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

A blog editor


A blog will have an administration section that will allow us to update the blog using the Web. This will be accessible through the address http://localhost:8080/admin, using the admin login as the username and Password1 as the password (both case sensitive).

Tip

Never ever ever use such a simple login in a real application!

The admin section of the blog's website will consist of web forms. The forms will use the post method so that the blog server will have to detect this correctly in the _handleRequest method of the BlogServerApp class to handle the request. This is exposed by the method property of the request object, as shown in the following code snippet:

if (request.method == 'POST') {
  _handleFormPost(request);
}

POST requests still have a URI associated with them, allowing a decision over how to handle the input. For detailed information, let's take a look at the following code snippet:

 void _handleFormPost(HttpRequest request) {
  if (request.uri.path == "/login") _performLogin...