I am very new to the dart programming any help is appreciated.
void main() {
var server = new HttpServer();
server.listen('127.0.0.1', 8080);
server.
addRequestHandler(
accept(HttpRequest function) => acceptInput(request, response), handler);
}
I want to add the function below to the request handler.
server.addrequestHandler()
I would like to do this so that I can add many request handlers as such including one for websockets
A sample or a tutorial would be very helpful.
I want to keep each handler in a separate function just for simplicity.
void acceptInput(HttpRequest request,HttpResponse response){
print(request.connectionInfo.toString());
print(request.queryParameters.toString());
response.outputStream.write('Hello dude'.charCodes);
response.outputStream.close();
}
Note:I know my void main code is wrong I need help to make it correct so that it incorporates the acceptInput Function.
Actually, you’re really close.
Try this:
Where
handleSaveandhandleDeleteare just functions, like: