Run Local Web Servers
Run a local web server on your local computer to test your API integrations.
To test asynchronous requests and code written in a server-side programming language (such as, Node.js or PHP), you need access to a developer server or the ability to run a local web server (localhost). Running a local web server lets you render web pages locally in a browser without making them publicly available to other people.
To enable development and testing on local computers, some Square APIs have reduced security requirements when calls are made from localhost. For example, the Square payment form iframe does not load on HTTP websites unless they are served on localhost. To take advantage of these reduced security requirements when testing, you must serve local pages using the "localhost" keyword instead of an explicit IP address (such as, 22.214.171.124).
Some programming language interpreters include a built-in web server that you can use for development and testing purposes. To start a built-in web server:
|Language||Local web server command||Default URL|
|PHP||$ php -S localhost:8000||http://localhost:8000|
|Rails||$ rails server||http://localhost:3000|
|Python||$ python -m SimpleHTTPServer 8000 (Python 2)
$ python -m http.server 8000 (Python 3)
|Node.js (Express framework)||$ npm start||No default. Must be explicitly configured programmatically: