Heroku has Betrayed Developers. Deploy your Python APIs with Deta Cloud Instead
The easiest way to deploy your Python API for free — using Deta Cloud (and not Heroku).
TLDR: Ditch Heroku. Deta Cloud is the easiest way to deploy python code to the cloud.
Introduction: Heroku Bad!
Heroku (vis-à-vis Salesforce) has betrayed developers. This goes beyond their recent announcement of eliminating their free plans (which they’ve astonishingly blamed on developers), beyond their unspoken feature freeze, and perhaps beyond the devastating security breach they’ve experienced and resisted telling the public about until outsiders sounded the alarm (to this day, they have not disclosed the full extent of the breach — I’m hoping the AG’s office brings them to court so we can see the damage and hold them accountable). Heroku’s / Salesforce’s betrayal comes from deprioritizing developers who use their product, disempowering developers inside their own organization, and for neglecting the trust developers placed in them.
Alternatives to Heroku
Needless to say, I’ve been looking for a different platform to deploy my API’s. There are many Heroku alternatives and I’m honestly feeling overwhelmed by the thought of evaluating all of them. However, I did find one Heroku alternative which I did like.
Have a Heroku alternative you think is really cool? Leave a comment below and I’ll do my best to try it out (and maybe write about it). My time is limited, so I will only be able to get to a few.
DEPLOYING A PYTHON API TO DETA CLOUD
Deta describes itself as “the universe’s most developer friendly cloud platform.” Deta is also free — according to their site, “forever.”
Let’s see if their platform holds up to their testament.
1. Create a Python API (using FastAPI) to deploy:
Let’s create a simple API using FastAPI (python’s most popular web development library), which we’ll be deploying to deta.
1.1 Create a main.py file with your FastAPI code:
⚠️ NOTE: The entry point to your API must be a file named
Sample API code (I recommend you use this for your first iteration):
Learn more about FastAPI here.
dependencies in a requirements file:
requirements.txt file and add
fastapi as a requirement.
Bash command to do this is below:
NOTE: Feel free to do with a visual editor too, whichever you prefer.
echo "fastapi" >> requirements.txt
1.3 Store secrets:
.env file to store your secret value:
echo "SECRET_VALUE=pickles" >> secret/.env
2. Test your API Locally:
Let’s make sure it’s working locally before deploying anything.
2.1 Install requirements
- Make sure you have
- Also make sure you have
uvicorninstalled. (Don’t include as a requirement though, since this is only used when running locally.)
- You can install both of these by running
pip install fastapi uvicorn(If this doesn’t work, try switching
2.2 Load your secret value:
2.2 Launch FastAPI local server:
uvicorn main:app --reload --port 8000
2.3 Test out local API endpoints:
- Navigate to
localhost:8000— you should hit your api’s endpoint!
- Navigate to
localhost:8000/secret— you should hit your api’s secret endpoint! 🎉
- Bonus: View the richly formatted swagger UI by navigating to
3. Deploy to Deta
3.1 Install Deta CLI (Documentation Link)
If you’re on a mac, execute the following:
curl -fsSL https://get.deta.dev/cli.sh | sh
If not on a mac, follow the documentation guide for correct installation command.
3.2 Verify the CLI is installed:
Open a new terminal window (if you re-use the same terminal session, things may not work for you).
If you get a response, you are done! 🎉
If you get the error:
zsh: command not found: deta that means your terminal cannot find the executable program. Make sure that
deta was installed correctly. Try exiting terminal and opening a new window. (Still have issues? Join their Discord and folks will help you.)
3.3 Login to Deta (and sign up for an account)
For housekeeping sake, make sure you are in the same directory as your code. Login with:
Here’s what happens next:
- Your default browser will open up to deta’s login page.
- You will be prompted to sign up for an account.
- Following that, you will need to confirm your email address.
- Then you sign in again (make sure it’s the same link as the url in your terminal)
If you get the message
Logged in successfully. then you are done! 🎉
3.4 Create a new deta project
This is done through the UI. (I don’t see any support for CLI configuration — maybe they’ll build that soon.)
- If your browser is closed, log back into Deta’s web interface: https://web.deta.sh/home
Create First Projectand choose a location near-ish to you.
3.5 Create a new “micro” (Deta’s name for an app):
# Choose a name for your micro
export MICRO_NAME=getting-started-with-deta# This command does the thing
deta new --name $MICRO_NAME --python
Verify that this worked by executing the following:
cat .deta/prog_info If stuff is printed to the console, then this file exists and you are good.
3.6 Add your environment variables to Deta
This syncs your secrets to the cloud. Documentation link: Deta Setting Environment Variables
deta update -e secret/.env
3.7 Enable Logging
Also possible through the UI. Documentation Link: Visor (Logs)
deta visor enable
3.8 Deploy! ⭐️
Note: Once you are authenticated and your project is configured, you can deploy changes to your API with the above command. (It’s that simple.)
4. Test out your API on Deta Cloud
Navigate to your project in Deta Cloud and find the URL specific to your micro.
Alternatively, list information about your micro by executing:
If you have
jq installed, you can get the url by executing:
deta details | jq -r '.endpoint'
😎 Want to do something cool? Open your browser directly from terminal:
deta details | jq -r '.endpoint' | xargs open
4.1 Test out your endpoints:
(I’ll be posting the links to mine, so you can see what to expect)
We’re done! 🎉
5. Advanced Stuff / Further Reading
If I had more time, I would do a further in depth review of these features. Instead, I’ll link em’ to their docs:
It is remarkably easy to deploy python code to Deta. Their platform is a bit in its infancy, exhibited in their sparse documentation and sometimes ambiguous CLI error messages. Nonetheless, these are not particularly egregious pain points and are definitely solvable.
My experience with the platform is highly positive. Considering Deta is a new company with fewer than 15 employees, I am deeply impressed. Further, I anticipate that Deta will rise to become more popular among developers. (I know I will be recommending Deta to new developers.)
Does Deta’s claim as “the universe’s most developer friendly cloud platform” check out?
I’ve worked with several of the major public clouds and countless other cloud technologies. Deploying python code to Deta has been the easiest and most developer friendly experience I’ve had so far. So YES.
Deta Cloud is indeed the easiest and most developer friendly cloud platform I’ve ever worked with.