如何将简单的dart Web服务部署到apache服务器?
我有一个非常简单的dart Web服务,我想将其部署到apache Web服务器如何将简单的dart Web服务部署到apache服务器?,apache,dart,Apache,Dart,我有一个非常简单的dart Web服务,我想将其部署到apache Web服务器 #import('dart:io'); void main() { HttpServer server = new HttpServer(); server.listen('127.0.0.1', 8080); server.defaultRequestHandler = (HttpRequest request, HttpResponse response){ // response.output
#import('dart:io');
void main() {
HttpServer server = new HttpServer();
server.listen('127.0.0.1', 8080);
server.defaultRequestHandler = (HttpRequest request, HttpResponse response){
// response.outputStream.write("hello World".charCodes());
// response.outputStream.close();
File f = new File("test.txt");
//File f = new File("index.html");
f.exists().then((bool exist){
f.openInputStream().pipe(response.outputStream);
});
};
}
当您使用GET 127.0.0.1:8080从浏览器中调用时,它将读取一个文件test.txt并在浏览器中显示输出
如何将其部署到apache Web服务器的某个在线位置?尝试mod_dart()。mod_dart可能会起作用,但您也可以在dart服务器前作为代理运行apache。node.js的许多部署在前面都有一个用于负载平衡、缓存等的代理。这种技术同样适用于Dart。这是我担心的。我希望有新的东西,但现在dart项目已经失败了。(对于2012年阅读本文的人)由于上述代码在独立的Dart VM中运行良好,您能否澄清为什么要“将其部署到apache Web服务器”?这可能有助于我们更准确地回答这个问题。谢谢我在django(使用ubuntu的vm)上运行的Web服务很少,在webApi(IIS)上运行的Web服务也很少。我想安装一个新的vmubuntu服务器,安装apachewebserver,然后运行简单的dart webservices。用户应该能够通过HTTP POST或GET发送数据,也可以接收数据(xml或json)