Run Local Web Servers
Run a local web server on your local computer to test your API integrations.
Why run a local web server?
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.
Test Square APIs with a local web server
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, 121.0.0.1).
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:
Open the Mac Terminal or Windows Command Prompt.
Navigate to the root folder containing the code you want to test.
Enter the language-specific command from the following table:
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) |
http://localhost:8000 |
Node.js (Express framework) | $ npm start | No default. Must be explicitly configured programmatically:app.listen(portNumber);
|
Previous
< Test in Unsupported Regions