Skip to content

Instantly share code, notes, and snippets.

@venkatd
Last active August 1, 2019 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save venkatd/f67728fb2ed365233dabde42e6190eb8 to your computer and use it in GitHub Desktop.
Save venkatd/f67728fb2ed365233dabde42e6190eb8 to your computer and use it in GitHub Desktop.
import 'dart:io';
Future<void> startPlayServer(int port) async {
HttpServer server = await HttpServer.bind(
InternetAddress.loopbackIPv4,
port,
);
await for (var request in server) {
_handleRequest(request);
}
}
void _handleRequest(HttpRequest request) async {
try {
await play();
await request.response.close();
} catch (e) {
print('Exception in _handleRequest');
print(e);
}
}
Future<void> play() async {
print("hello at" + DateTime.now().toIso8601String());
return null;
}
{
"version": "2.0.0",
"tasks": [
{
"label": "play",
"type": "shell",
"command": "curl",
"args": [
"http://localhost:9999"
],
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment