Getting Started

Configuring & Installing the Deta CLI

To install the Deta CLI, open a Terminal and enter:

curl -fsSL | sh

This will download the binary which conatins the CLI code. It will try to export the deta command to your path. If it does not succeed, follow the directions output by the install script to export deta to your path.

Logging in to Deta via the CLI

Once you have successfully installed the Deta CLI, you need to login to Deta.

From a Terminal, type deta login.

This command will open your browser and authenticate your CLI through Deta's web application.

Upon a successful login, you are ready to start building Micros.

Creating Your First Micro

To create a micro, navigate in your Terminal to a parent directory for your first micro and type:

deta new --python first_micro

This will create a new Python Micro in the 'cloud' as well as a local copy inside a directory called first_micro which will contain a file.

The CLI should respond:

"name": "first_micro",
"runtime": "python3.7",
"endpoint": "https://<path>",
"visor": "enabled",
"http_auth": "enabled"

Save this endpoint URL somewhere, as we will be visiting it shortly.

Updating your Micro: Dependencies and Code

Setup and Dependencies

Enter the directory first_micro, and then create a file, requirements.txt, which tells Deta which dependencies to install.

Let's add flask to requirements.txt and save this file locally.


Updating Code Locally

Let's also edit the file so that your Micro responds to HTTP GET requests with Hello World.

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

Deploying Local Changes

After you have updated your requirements.txt and / or your code locally, use a deta deploy command to update your Micro.

deta deploy

The Deta CLI will notify you if your code has updated as well as if the dependcies were installed

Successfully deployed changes
Updating dependencies...
Collecting flask
Downloading (94kB)
Collecting Werkzeug>=0.15 (from flask)
Downloading (298kB)
Collecting itsdangerous>=0.24 (from flask)
Collecting Jinja2>=2.10.1 (from flask)
Downloading (125kB)
Collecting click>=5.1 (from flask)
Downloading (82kB)
Collecting MarkupSafe>=0.23 (from Jinja2>=2.10.1->flask)
Installing collected packages: Werkzeug, itsdangerous, MarkupSafe, Jinja2, click, flask

Visiting our Endpoint

Let's visit the endpoint the endpoint we saved earlier.

(If you didn't save it, simply type deta details into the CLI, which will give you the endpoint alongside other information about your Micro).

Open up your endpoint in a browser. You might be prompted to log in to your deta account on visiting your endpoint for the first time.

You should see Hello, World

If you're accessing the endpoint from not in a browser (like from curl) or if you have disabled cookies in your browser, the response will be:


This is because Deta Auth is protecting the endpoint from unauthorized access.

Opening Your Micro To the Public

Let's use one last command to open up the endpoint to the public:

deta auth disable

The CLI should respond:

Successfully disabled http auth

Congratulations, you have just deployed and published your first Micro!