Gero
Gero

Reputation: 13553

how to deploy a simple dart webService to apache server?

I have a very simple dart webService and i would like to deploy it to apache webServer.

#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);
    });
  };
}

When you call with GET 127.0.0.1:8080 from your browser, it reads a file test.txt and shows output in your browser.

How do i deploy that to an apache webserver somewhere online?

Upvotes: 1

Views: 969

Answers (2)

Seth Ladd
Seth Ladd

Reputation: 120529

mod_dart might work, but you can also run Apache as a proxy in front of your Dart server. Many deployments of node.js have a proxy in front for load balancing, caching, etc. This same technique applies to Dart.

Upvotes: 4

Shannon -jj Behrens
Shannon -jj Behrens

Reputation: 5030

Try mod_dart (https://github.com/sam-mccall/mod_dart).

Upvotes: 0

Related Questions