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 CLIOnce 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 MicroTo 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.
#
Creating a Micro Under a Specific ProjectThis will create a new Micro under <your-project>
in the 'cloud'.
#
Updating your Micro: Dependencies and Code- JavaScript
- Python
#
Setup and DependenciesEnter 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 LocallyLet's also edit and save the index.js
file locally so that your Micro responds to HTTP GET
requests with Hello World.
#
Deploying Local ChangesAfter 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 dependencies were installed
#
Setup and DependenciesEnter 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 LocallyLet's also edit the main.py
file so that your Micro responds to HTTP GET
requests with Hello World.
#
Deploying Local ChangesAfter 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 dependencies were installed.
#
Visiting our EndpointLet'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 PublicLet'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!
#
IssuesIf you run into any issues, consider reporting them in our Github Discussions.