DEV Community

Ekpetchou Achille Ezoba
Ekpetchou Achille Ezoba

Posted on Originally published at sahelescale.com

How to Deploy a Flask App Online for Free

You built a Flask app that works on your computer. Now you want other people to use it. Here is a simple, free way to put it online.

Before you start

  • A working Flask app (even a very small one)
  • A free GitHub account
  • A free account on a hosting service such as Render

Free plans change over time and have limits (for example, a free app may go to sleep after a period without visitors), so check the current terms on the hosting site.

Step 1: Prepare your project

Your project folder should look like this:

my-app/
  app.py
  requirements.txt
  templates/
  static/
Enter fullscreen mode Exit fullscreen mode

Here is a minimal app.py:

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello from my Flask app!"
Enter fullscreen mode Exit fullscreen mode

Step 2: List your dependencies

Create a file called requirements.txt that names every package your app needs. At minimum:

flask
gunicorn
Enter fullscreen mode Exit fullscreen mode

Gunicorn is the production server that will run your app online. Flask's built-in server is only for testing on your computer.

Step 3: Upload your project to GitHub

  1. Create a new repository on GitHub.
  2. Upload your project files to it (you can drag and drop them in the browser).
  3. Do not upload passwords or secret keys. Keep those out of your code.

Step 4: Create the service on Render

  1. Sign up on Render and connect your GitHub account.
  2. Choose New, then Web Service, and select your repository.
  3. Set the Build Command to pip install -r requirements.txt
  4. Set the Start Command to gunicorn app:app
  5. Pick the free instance type and click deploy.

The part app:app means: the file app.py, and the variable named app inside it. If your file or variable has another name, change it here.

Step 5: Open your app

After a few minutes, Render shows a public link for your app. Open it in your browser and share it with a friend.

Common problems

  • Build fails: a package is missing from requirements.txt. Add it and redeploy.
  • "Application error" on the page: check the logs on Render. The start command is often the cause.
  • App is slow on the first visit: free apps often sleep when unused and wake up on the next visit.
  • Data disappears: free hosting usually does not keep files you save on the server. Use a proper database for anything important.

A free alternative

PythonAnywhere also offers a free plan that is friendly to beginners and made for Python web apps. It is a good option if you prefer a simple control panel to a GitHub-based setup.

Final thoughts

Deploying your first app feels hard until you do it once. Start with a tiny project, get it online, and improve it from there.

More beginner guides: sahelescale.com

Top comments (0)