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.004

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's start by clicking the following to create a virtual environment.

python3 -m venv env
source env/bin/activate
apt -y install python3 python3-pip

With our virtual environment set up, we're ready to set up the Django framework and create our rest project. Click the following.

pip install djangorestframework
django-admin startproject rest .
python manage.py migrate

Let's start our service, by clicking the following, just to show that we can run the service. It won't do much... yet!

python manage.py runserver

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. We'll execute the following command from a separate terminal (just click the following).

curl 127.0.0.1:8000

Excellent! We have a running HTTP service!