How Do You Use Python Eve as a RESTful Endpoint on an Ubuntu Server?

Problem scenario
You want to use Python Eve to test it out.  You also want to create a RESTful endpoint on an Ubuntu Linux server.  How do you do this?

1.  Install Eve on the Ubuntu server.  Here is one way:

sudo apt-get -y update
sudo apt-get -y install python python-pip
sudo pip install eve

An alternative way to install it is given here.

2.  Run these five commands:

contint = {'MONGO_HOST': 'localhost', 'MONGO_PORT': 27017, 'MONGO_DBNAME': 'the_db_name', 'DOMAIN': {'contacts': {}}}
from eve import Eve
app = Eve(settings=contint)

3.  From another terminal (e.g., open another command prompt from your desktop or create a duplicate Putty session to the server), run this command:

curl http://localhost:5000

Look at the output on the first terminal.  You should see an HTTP status code of 200 and other information.

Leave a comment

Your email address will not be published. Required fields are marked *