les 0.1.0 copy "les: ^0.1.0" to clipboard
les: ^0.1.0 copied to clipboard

Light Efficient Server - for creating servers on Dart. Inspired by ExpressJS.

example/example.dart

import 'package:les/les.dart';

void main(List<String> args) {
  // Creates instance of [Server]
  Server()
  // Add middlewares
  ..use(bodyParser)
  ..use(buildStaticFilesHandler())
  // Add [Routes]
    ..add(routes)
    // Start listen for requests
    ..listen(7575);
}

// Define [Route]s that describe answers for concrete requests
final routes = Router('/')
  ..add(Route(
        // Path will be transformed to RegExp => (:number)
        r':a(\d+)',
        (ctx) => ctx.send('Hello get')
      ))
  ..add(Route(
      'post',
      (ctx) => ctx.send('Hello post'),
      method: HttpMethod.post
      ));
0
likes
40
pub points
0%
popularity

Publisher

unverified uploader

Light Efficient Server - for creating servers on Dart. Inspired by ExpressJS.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

http_server, path_to_regexp

More

Packages that depend on les