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!
Build a Cassandra Python REST Service
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
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).