June 2017
Intermediate to advanced
873 pages
18h 9m
English
In the previous recipe, we made a client app that sends its data to a web server in JSON format. In this recipe, we will make the web server that receives this data step by step, possibly process it, and then send it back to the client. You can find the code in the script server\webserver.dart in the project post_form.
Perform the following steps to make this work:
import 'dart:io';
const HOST = '127.0.0.1';
const PORT = 4040;
void main() {
HttpServer.bind(HOST, PORT).then(acceptRequests, onError: handleError);
}acceptRequests function describes how the web server handles incoming requests based on their method as follows:void acceptRequests(server) ...
Read now
Unlock full access