Configuring & Installing the Deta CLI
To install the Deta CLI, open a Terminal and enter:
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
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:
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
The CLI should respond:
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
main.py file so that your Micro responds to
HTTP GET requests with 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.
The Deta CLI will notify you if your code has updated as well as if the dependcies were installed
Visiting our Endpoint
Let's visit the endpoint ( from the endpoint URL 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:
The CLI should respond:
Congratulations, you have just deployed and published your first Micro!