DART应用程序可以托管在像Apache这样的Web服务器上吗?

Raj*_*san 5 dart

我的印象是DART程序无法托管在网络服务器中.有人可以赐教我这个吗?

Chr*_*ett 6

是的,它可以(虽然这不是它的主要用例).

来自Google Plus,2013年2月28日:

最后我设法让Dart在Apache CGI中工作!我没有找到任何关于此的信息,所以我自己尝试了.我是这样做的(Apache 2.2和Ubuntu)......

来自news.dartlang.org,2012年5月26日

今天,Sam McCall宣布了mod_dart:能够运行嵌入在Apache中的Dart应用程序!就像PHP,Perl,Python和许多其他脚本语言一样,您现在可以使用Dart从Apache Web服务器内部为服务器端Web应用程序提供支持.

这两者都是"概念证明",但它们表明Dart可以嵌入到Apache等Web服务器中.

现在"但......"

虽然已经证明Dart可以嵌入到Web服务器中,但Dart更像node.js,因为服务器端dart二进制文件为应用程序提供了一个VM.该应用程序可以包含自己的Web服务器,例如:

main() {
  var server = new HttpServer();

  server.addRequestHandler(
     (req) => true,   // matcher - should this function handle this request?
     (req, res) {     // handler - what should happen when this request matches?
       res.outputStream.write("${req.method}: ${req.path}"); // eg: GET: /foo
       res.outputStream.close();
     });

  server.listen('127.0.0.1', 8080);
Run Code Online (Sandbox Code Playgroud)