···
import { serve } from "https://deno.land/[email protected]/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
req.respond({ body: "Hello World\n" });
}
···
······
import 'dart:io';
Future main() async {
var server = await HttpServer.bind(
InternetAddress.loopbackIPv4,
8000);
print('Listening on localhost:${server.port}');
await for (HttpRequest request in server) {
request.response.write('Hello world\n');
await request.response.close();
}
}
······
1
bysgatn3 224 天前 via Android
其实完全不像。
dart 有太多令人感到诡异的语法,特别是函数式。 我觉得 C#跟 JS+TS 更像。 |