startServer function

Future<HttpServer> startServer(
  1. String html,
  2. int port
)

Implementation

Future<HttpServer> startServer(String html, int port) async {
  final server = await HttpServer.bind('127.0.0.1', port);
  server.listen((req) async {
    req.response.headers.add('Content-Type', 'text/html');
    req.response.write(html);
    req.response.close();
  });
  return server;
}