Deta – Free Heroku alternative, Step by Step Guide to Deploy a Python app

The deta.sh cloud platform, is a free alternative to Heroku. This article is a step-by-step guide to deploying a Flask Python app for free.

Heroku is a good cloud platform to deploy and scale apps, but Heroku is no longer free. We can use Deta.sh cloud to freely deploy a Python app.

Create a free Deta account

Fire go to deta.sh and create an account using your email ID (Credit card not required )

deta welcome screen

Next, we need to select a region or auto.

Select region for deta

Install deta CLI

Next, we need to install deta CLI, using this CLI we can deploy our Python web app. Run the following command to install it.

For Windows users run the below command in PowerShell.

iwr https://get.deta.dev/cli.ps1 -useb | iex

For Linux/Mac users run the below command.

curl -fsSL https://get.deta.dev/cli.sh | sh

After the installation, open the terminal and type deta command and ensure that the command is working. You will get similar output as below.

Deta command output

Create a Python web app

Let’s create a Python web app.

Type the following command in the terminal here cool_app is the name of our web app.

deta new --python cool_app
Create python app using deta

From the output, we can see the endpoint URL https://1wu115.deta.dev (This is our web app’s URL).

Open the app URL in the browser. Tada !!! our app is running. To see the code of our app navigate to cool_app folder. We can see main.py file.

Deta app folder

Update app as a Flask app and deploy changes

Enter the directory cool_app and then create a file, requirements.txt, which tells Python dependencies to install.

flask

Next, open the main.py in your favorite code editor and remove its content and paste the below code.

from flask import Flask

app = Flask(__name__)

@app.route('/', methods=["GET"])
def greet():
    return "Hello from NoloWiz"

Code is simple it will greet the user with a message. Let’s deploy it.

To deploy these changes, simply run the command.

deta deploy

After the deployment let’s open our app URL in the browser.

Hello from Python app deta

It works!!!

Conclusion

There you have it, a simple free way to deploy and experiment with your Python web apps. Happy coding.