NilsH
NilsH

Reputation: 13821

Running PhantomJS as a server

I'm looking into using PhantomJS to generate static html from a dynamic AngularJS app that can be indexed by google. What I want to do is to start a PhantomJS server that sits behind a proxy and gets the ?escaped_fragment requests. PhantomJS appears to be (mainly) a command line tool (I have read the FAQ explaining why it's not a regular node module), and although I have found a couple of nodejs bridges for it, they appear to be a little bit unreliable.

Therefore, I'm looking into running PhantomJS with an embedded HTTP server. I have seen some examples of a built in webserver in PhantomJS, but I'm not sure if it's meant to be used this way? If not, is it possible to have PhantomJS use regular node modules, like e.g. expressjs, so I can use the PhantomJS runtime to also host a simple webserver?

Upvotes: 3

Views: 1469

Answers (1)

Matt Sergeant
Matt Sergeant

Reputation: 2862

The bridge node-phantom isn't unreliable (phantom-node is unreliable, and overcomplicated, so don't use that one).

Phantom itself can sometimes be a bit unreliable, but it tends to be with specific web sites.

I'm not convinced Phantom is the right solution for you though - you might want to check out JSDom instead, and just have your code run in-process.

Upvotes: 2

Related Questions