Migrating production infrastructure? Get up to ₹10,000 in migration credits. Apply now
voroaBlog
Web Services

Python Hosting in India for Flask and FastAPI Apps

· · 2 min read

Python Hosting in India for Flask and FastAPI Apps

Python hosting in India is often sold as “cPanel with Python support”. That works for a script. It is awkward for a Flask or FastAPI app that needs its own process, its own packages and a clean way to ship updates. This post covers what a small Python web app needs to run well in production, and the mistakes that usually stop it working on the first deploy.

A Flask or FastAPI app running behind a production server on a platform in India

Advertisement

Pick the right server

The built-in development servers are not built for production traffic. Use a production server instead.

Flask

Flask is a WSGI app. Run it with Gunicorn:

bash
gunicorn app:app --bind 0.0.0.0:$PORT

The Flask deployment docs list other servers if you prefer one.

FastAPI

FastAPI is an ASGI app. Run it with Uvicorn:

bash
uvicorn main:app --host 0.0.0.0 --port $PORT

Both read the port from $PORT, which Voroa sets for you. Bind to 0.0.0.0, not 127.0.0.1.

Pin your packages

List every package with a version in requirements.txt. An unpinned package can change between two builds and break an app that worked yesterday. Keep development-only tools out of the production list.

Check your Python version

If you need a specific version, say so in the project. The build uses it instead of guessing.

Set the build and start commands

Most Python apps need no build command beyond installing packages. The start command is the server line above. Both are editable later; the build and start commands guide explains each field.

Keep secrets out of the code

API keys and database URLs belong in environment variables. On Voroa you add them on the service’s Environment page, and the service redeploys to pick them up. Values are stored encrypted and are not shown back to you after you save them. See environment variables.

Add a database

For data that must survive a restart, use managed PostgreSQL and read its URL from DATABASE_URL. SQLite files on a service’s disk are not a database for production.

Ship updates from GitHub

Connect your repository once. Every push builds and starts a new release, and the old one keeps serving until the new one is ready. If a release is bad, roll back to the previous version. Keep a /health route that returns 200 so a broken release is caught before it takes traffic. The setup is in our Python deploy guide.

Why a Flask or FastAPI app fails on its first deploy

  • ModuleNotFoundError: the package is missing from requirements.txt.
  • The URL does not answer: the server is bound to 127.0.0.1 or a hard-coded port.
  • Works locally, fails in production: an environment variable you have locally is not set on the service.

What it costs

On Voroa you can start on the free size, which has 512 MB of memory (subject to free capacity). Paid sizes start at Rs 298 a month plus GST, and you get a GST invoice in rupees.

Host your Python app on Voroa

For a full Django project, read Django hosting in India. For everything a Python web service includes, see Python app hosting on Voroa.

Advertisement