Do not clone the repo if you are learning, just follow along.
Make an account and confirm it, it's free.
Follow these instruction to get the Deta CLI up and running.
To create a directory, in the terminal, run the following:
mkdir fastapp
Then change into the directory:
cd fastapp
and make two empty files:
touch main.py requirements.txt
In the requirements.txt
file add fastapi
:
fastapi
In main.py
, add the following code:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def hello():
return "Hello from Deta!"
To deploy to Deta, run the following command inside the project directory, aka fastapp
:
deta new
The deployment should take a few seconds. Make sure to notice the Micro URL, it will look somethign like this:
https://xyz.deta.dev/
You can open it in your browser and it if everything has worked, then you will see:
Hello from Deta!
You can deploy changes to Deta using this command:
deta deploy
You could also use the convenient watch
command for auto-deploys
To open VISOR, run the following:
deta visor open
To protect your API, so no one else but you could access it, run the following:
deta auth enable
You can re-open you API by running:
deta auth disable
To create an API key, run the following command
deta auth create-api-key --name name-of-the-key
Make sure to keep it in a secure place.