Getting Started
Configuring & Installing the Deta CLI#
- Mac
- Linux
- Windows
To install the Deta CLI, open a Terminal and enter:
To install the Deta CLI, open a Terminal and enter:
To install the Deta CLI, open PowerShell and enter:
This will download the binary which contains 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:
- JavaScript
- Python
This will create a new Node.js Micro in the 'cloud' as well as a local copy inside a directory called first_micro which will contain an index.js file.
The CLI should respond:
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 main.py file.
The CLI should respond:
Save this endpoint URL somewhere, as we will be visiting it shortly.
Updating your Micro: Dependencies and Code#
- JavaScript
- Python
Setup and Dependencies#
Enter the directory first_micro, and then run the shell command:
This will initialize a Node.js project in your current directory with npm's wizard.
What is important is that the main file is index.js.
After following the npm wizard, let's add a dependency by running:
Updating Code Locally#
Let's also edit and save the index.js file locally so that your Micro responds to HTTP GET requests with Hello World.
Deploying Local Changes#
After you have updated your dependencies (documented in a package.json file) 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
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 not accessing the endpoint from 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!