V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
chenhui7373
V2EX  ›  Dart

deno 和 dart 好像啊

  •  
  •   chenhui7373 · 2020-11-04 14:39:13 +08:00 · 1944 次点击
    这是一个创建于 1274 天前的主题,其中的信息可能已经有所发展或是发生改变。

    ···

    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();
    

    }

    }

    ······

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1050 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 23:45 · PVG 07:45 · LAX 16:45 · JFK 19:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.