Wiring up a backend server
In this section, we will make use of the $http
module of AngularJS to make RESTful calls to a simple backend server. The backend server here is based on Facebook's Tornado Framework (https://github.com/facebook/tornado/), but the fact is that you can make RESTful calls using Express.js (http://expressjs.com/) or any other framework that you like.
Before you get started with this section, you will need to have MongoDB (http://www.mongodb.org/), Python 2.7.x, and the Tornado web server installed. You will also need to install a Python library called tornado-cor
(https://github.com/globocom/tornado-cors), which facilitates the use of cross-origin resources between your AngularJS app and server.
Coding our server
The main idea of the Python Tornado server is as follows:
We have one endpoint, where this endpoint will receive a
GET
orPOST
request from our AngularJS app.Depending on the URL argument received, the corresponding handler will perform
GET
on all to-do items...