Create Serverless Application with Nimbella & Python

Athithan Raj P
4 min readOct 29, 2020

We can create a fully functional serverless application which can be accessed from anywhere with in sometime with nimbella & python by following below. i would like to write a demo on user registration which every web application should have by default

Create your First Serverless with Python & Nimbella:

1.Create a new nimbella Account by visiting nimbella

2.Install Nim CLI , execute below command in terminal
For Ubuntu → sudo apt install nim

3.Login with Nim CLI with Token from nimbella’s setup page

4.Create a folder named Packages & a file named project.yaml File

5.Create a folder having the name(<appName>) of your application inside packages folder. in my case , i have the name as “myapp”

6.Inside that application folder create folder with the name (<endPointFolderName>)which represents end point of your application. In my case , i have the name as “userRegistration”

7.Create a database.py file to invoke DB operations

8.Create __main__.py file and write a main function which return the response inside a json attribute named “body”

9.Create a build.sh file which will be creating your virtual environment for deployment

10.create requirements.txt where you will be mentioning the required python packages. Since i have used Pymongo for DB connection, i have pymongo in my requirements.txt

11.Modify the project.yaml as below

10.Now the Folder direcctory looks as below. navigate to the root directory which contains the packages folder.

11.In nim CLI, Execute nim’s deploy command as below to deploy .
command →“nim project deploy <project directory”

12.Execute below command to know your workspace in nimbella

Command → “nim auth current”

In Nimbella, each directory name is considered as end point and the syntax can be defined as https://<workspace>-apigcp.nimbella.io/api/<appName>/<endPointFolderName>

So as per My project structure my end point for userRegistration would be
https://pathitha-4mpb1smu66t-apigcp.nimbella.io/api/myapp/userRegistration

With all these steps, our serverless app is deployed and ready to serve request from any where.
PostMan is a API Testing tool Which is widely used by most of the developers.

we can register our first user through post man api call as below.

Summary:

  1. Create a nimbella account and login with nimbella login key in nim cli
  2. Create project as per the structure and implement the logic
  3. Deploy it nimbella by executing nim deploy command and access it from anywhere
  4. Access it via post man as api and start interacting with your app.

How I learnt:

Nimbella, PostMan , Hackerearth were conducting a #DeveloperIPLChallenge hackathon event where everyone needs to create app with theme as social good. We created a app which addresses the struggles students face through remote education. It was great learning experience. If you have idea, write code for it and nimbella will take care of the rest (Scalability).

--

--