Difficulty: Intermediate
Estimated Time: 20 minutes

The first step to creating a microservice is to create a service. Let's see how to add a REST front end on Cassandra with Python and Django!

In this scenario, we'll learn how to:

  • Install the necessary Django framework
  • Configure a REST service with Django
  • Connect the Django REST service to Cassandra

Python makes things easy and Django makes them even easier! We'll get you started!

ver 0.002

In this scenario, we learned how to:

  • Install the necessary Django framework
  • Configure a REST service with Django
  • Connect the Django REST service to Cassandra

This is a simple service, but it illustrates the important broad brush strokes.

Build a Cassandra Python REST Service

Step 1 of 7

Set up the Django server

In this step, we are going to set up the web server. Let' start by installing the necessary frameworks. To do this in Python, we want pip.

apt-get update
apt -y install python3-pip

With pip installed, we're ready to set up the Django framework and create our rest project.

pip install djangorestframework
django-admin startproject rest .

Let's start our service. It won't do much... yet!

python3 manage.py runserver &
sleep 3
clear

Notice that we started the service in the background so we can keep working. Let's hit the service to verify it's up and running. If the service is running, the following command will print out the HTML from the server.

curl 127.0.0.1:8000

Excellent! We have a running HTTP service!