Welcome back!

Forgot your password?

JavaScript with a proxy web app server

To use our JavaScript SDK, you need to combine it with a server-side proxy language. An application server creates a web server for your JavaScript code to proxy requests through. Note that web server implementations vary across languages. We've used PHP for all of our JavaScript tutorials, and this tutorial is designed to show you how to get set up in a different language.

We're using Python here, with the Twisted web application server. If you're using the default OS X Python, you already have Twisted and don't need to install anything. If you're using a different Python set up, you may need to install Twisted by running pip install twisted from the command line.

10At the top of the proxy-server.py file, we'll import a few resources from Twisted by adding the following lines:

from twisted.web.server import Site
from twisted.web.resource import Resource
from twisted.internet import reactor
from twisted.web.static import File

11In the same file, wrap the auto-generated code in a class and a render_Post function by adding the following lines of code immediately following all import statements using the appropriate indentation:

12 In the line where the tembooProxy.execute method is called, replace the httpPostData['temboo_proxy'] variable with the contents of the JavaScript client POST request, request.args['temboo_proxy'][0]. The new execute method should look as follows:

13Return the result of running the Choreo by adding the following line after calling the tembooProxy.execute method.

return result

14Add the following lines to the bottom of your code to create the file structure. First, we create root, a resource which corresponds to the root of the URL hierarchy. Then we create three more resources and attach them to the three URLs, our index.html JavaScript file, our temboo.js Temboo JavaScript library, and our ProxyServer.

15Last, we'll create a Site with the root resource instantiated in the previous step, associate it with a listening server port, and start the reactor by adding the following lines to the bottom of our python code.

factory = Site(root)
reactor.listenTCP(8000, factory)
reactor.run()

16In our index.html file, we need to confirm that the location of our server proxy, /proxy-server, is specified correctly.

Run the Server

18Navigate to your project folder in terminal, and start the application server by running the following command:

python proxy-server.py

19Go to the following URL in your browser:

http://127.0.0.1:8000

20Check the developer console and find the Choreo results:

What's Next?

Once you've got your code up and running, you're ready to move on and do more. From monitoring your running applications, to moving your generated Temboo code to your preferred development environment and sharing it with colleagues, collaborators and friends - we've got you covered.

Commit Code to GitHub

Commit Temboo-generated code directly to GitHub and share with the world. Learn more.

Need help?

We're always happy to help. Just email us at support@temboo.com, and we'll answer your questions.