PhantomJS Tutorial
WebPage Module
File System Module
System Module
Web Server Module
Miscellaneous
PhantomJS Useful Resources
Selected Reading
- PhantomJS - Methods
- PhantomJS - Object
- PhantomJS - Environment Setup
- PhantomJS - Overview
- PhantomJS - Home
WebPage Module
- PhantomJS - Child Process Module
- PhantomJS - Events/Callbacks
- PhantomJS - Methods
- PhantomJS - Properties
File System Module
System Module
Web Server Module
Miscellaneous
- PhantomJS - Examples
- PhantomJS - REPL
- PhantomJS - Testing
- PhantomJS - Network Monitoring
- PhantomJS - Page Automation
- PhantomJS - Screen Capture
- Command Line Interface
PhantomJS Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
PhantomJS - Properties
PhantomJS - Web Server Module Properties
PhantomJS uses an embedded web server called mongoose. Right now, PhantomJS cannot connect with any other production webserver. With respect to connection, it can deal with 10 connections at a time and more than 10 requests will be waiting in a queue.
To start a webserver, we need to use the following syntax −
var webserver = require (‘webserver’);
Let us understand the Port property, which is used to psten to the requests that are sent to the webserver.
port
The Port property for a webserver is used to psten to the request that are sent to it.
Syntax
Its syntax is as follows −
var server = require( webserver ).create(); var pstening = server.psten(port, function (request, response) {});
Example
Let us take an example to understand how the port property works.
var webserver = require( webserver ); var server = webserver.create(); var service = server.psten(8080,function(request,response){ }); if(service) console.log("server started - http://localhost:" + server.port);
The above program generates the following output.
server started - http://localhost:8080Advertisements