Deta Cloud, a free platform for developers

TL, DR

Deta Cloud is a free platform where you can deploy micro-APP. It includes serverless functions, a NoSQL database, and cloud object storage. You can use Python or Node.js to develop and deploy your app for free.

Deta Cloud

Deta Cloud is a new platform that you can use to deploy small projects. It is completely free, and provides you with the necessary infrastructure to publish your projects on the Internet.

You can deploy code in Python and Node.js. We will focus on the Python side of things. In order to use Deta you need to download and install the Deta CLI (documentation here). Deta CLI is available for Linux, Mac, and Windows. It requires a 64bits OS, so if you want to use a Raspberry Pi to test it please make sure you install the 64bits Raspberry Pi OS or another suitable OS.

The 64bits version of Raspberry Pi OS is quite hidden, you can find those OS images here. It is not yet officially supported, and it only works with Pi 3 and Pi 4 devices (more details here). You can burn the image to a microSD with Balena Etcher, insert in your Raspberry Pi and you are good to go.

After Deta CLI is set and good to go, you can login and start deploying to Deta Cloud!

Micros

Deta Micros are kind of equivalent to serverless functions. Every Micro gets its own sandboxed Linux VM, so it’s fully isolated. You can deploy additional static files with your code. It is perfect for Flask or FastAPI applications, either for API or a website.

Micros are stateless, it means after every execution they are reset to the starting status. If you want to save something you need to lean on Deta Base or Deta Storage (more on those below).

After deployment you get a Deta subdomain where your functions are accessible. You can change it or use your own domain. In this case, you need to update your DNS to point to Deta.

Micros example

This is a minimal example of a Flask application you can deploy on a Micro. The main file need to be called main.py in the root folder of your Micro.

from flask import Flask

app = Flask(__name__)

@app.route('/', methods=["GET"])
def hello_world():
    return "Hello World"

Once you deploy, the Deta CLI will return you the web address where this function is available. You can test it straight away with your browser!

Limitations for Micros

There is a 10 seconds limit for execution, so any function you deploy shouldn’t take longer than that to run. You can ask for an exception to raise the limit, but you’ll need to provide a justification. Another limit is the RAM per execution, capped at 128Mb. Also for this you can apply to have it raised.

An harder limit is the 250Mb for your code, assets, and dependencies. This includes all Python packages you may want to use (Flask, Pydantic, etc.). This forces you to be lean on the tools and assets you use.

Base

Deta Base is a simple but powerful noSQL database. It is quite similar to a MongoDB collection, each entry is treated like a dictionary. You can include a key when you insert a new entry, or it will be automatically generated. Keys need to be strings.

The Python SDK provides an easy way to execute the basic database operations: Put, Get, Delete, Insert, Put many, Update, Fetch. You can see below some basic example of usage.

from deta import Base

db = Base("db")  # name your Base
db.put({"name": "Luigi", "dev": True, "key": "1"})
db.get("1")  # get item by key
db.fetch()  # list all items
db.update({"name": "Paluigi", "key": "1"})
db.delete("1")

Deta Base also provides a good web UI to access the dataset, with possibility to perform all the basic operations on your data.

Limitations for Base

Base cannot store numbers (floats and integers) longer than 16 digits. Any number longer than this should be stored as string.

Keys need to be strings, it’s not possible to use numbers or other types.

Fetch retrieves a maximum of 1000 documents or 1Mb at a time. If your database is larger, you may have to call Fetch multiple times, providing the last retrieved key as a parameter to restart fetching from that point.

Drive

Deta Drive is a handy object storage, not dissimilar from S3. You have all the functions to store, retrieve, and delete files in the Deta SDK. Below you can find some examples of utilization.

from deta import Drive

files = Drive("reports")  # name your Drive
files.put("report.pdf", path="./report.pdf")
files.get("report.pdf")  # get file by name
files.list()  # list all files in a drive
files.delete("report.pdf")

Limitations for Drive

Drive provides a maximum of 10Gb storage per Deta account, combining all Drive instances under that account.

Deta Cloud summary

To sum everything up, Deta Cloud is a fantastic free cloud platform for individual developers, that help you to rapidly build and deploy simple projects. In my opinion, you should give it a try!

Related links

Do you like our content? Check more of our posts in our blog!