Deploy a Python FastAPI or Flask app with PostgreSQL in India
Put your dependencies in requirements.txt, make the app listen on the port given in the PORT variable, add a simple health route, and read the database address from DATABASE_URL. Then push to Nexovia or upload a zip: it builds the app, checks it, runs it as a non-root user in a sandbox in India and gives it HTTPS on your domain.
1. Prepare the project
- Dependencies: a
requirements.txtwith pinned versions, includinguvicornfor FastAPI orgunicornfor Flask. - Start command: for FastAPI
uvicorn main:app --host 0.0.0.0 --port $PORT; for Flaskgunicorn -b 0.0.0.0:$PORT app:app. - Health route: a
/healthzroute that returns 200, so a new version is only switched live when it really works.
2. Connect PostgreSQL
Request a managed database for the app. The connection string arrives as DATABASE_URL when the app starts; read it with os.environ and pass it to SQLAlchemy or psycopg. Run migrations, for example Alembic, as the release command.
3. Keep secrets out of Git
Do not commit .env files. Add keys such as an OpenAI or payment key as project variables; they are stored in a vault and given to the app at start. The release check stops a release that has a key written into the code.
4. Release and watch
Every push builds on a separate build server, is scanned, starts beside the current version and switches only after the health route answers. If something fails, the release page explains why in plain language, and one click rolls back.
Questions
Can I host a FastAPI app in India without Docker?
Yes. Nexovia builds Python apps from requirements.txt without a Dockerfile. If your project has its own Dockerfile, it is used instead.
Is there a Heroku alternative for Python in India?
Nexovia works like Heroku for Python apps: push code and it runs, with a managed PostgreSQL database, but the data stays in India and prices are in rupees.
How much does it cost to host a Python API with a database?
From ₹499 a month on the Solo plan, plus GST, including a 1 GB PostgreSQL database, file storage and a custom domain.