chenhui7373
V2EX  ›  Dart

deno 和 dart 好像啊

  •  
  •   chenhui7373 · Nov 4, 2020 · 3208 views
    This topic created in 2023 days ago, the information mentioned may be changed or developed.

    ···

    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 replies    2024-05-15 11:03:07 +08:00
    bysgatn3
        1
    bysgatn3  
       May 15, 2024 via Android
    其实完全不像。
    dart 有太多令人感到诡异的语法,特别是函数式。
    我觉得 C#跟 JS+TS 更像。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1009 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 22:20 · PVG 06:20 · LAX 15:20 · JFK 18:20
    ♥ Do have faith in what you're doing.