Deploying your Python applications online doesn’t have to cost money. There are free platforms available that make it easy to publish web apps built with frameworks like Flask or FastAPI. In this guide, we’ll walk you through deploying Python apps using PyLex and PythonAnywhere.
Make sure you have the following:
requirements.txt
file listing your dependencies.PyLex is a modern platform that allows you to deploy Python apps straight from GitHub. It supports auto-deployment, handles dependencies, and provides a free public URL.
Go to https://pylex.dev and sign up using your GitHub account.
Ensure your repository contains the following:
app.py
or main.py
as the entry point.requirements.txt
listing all needed packages.app = Flask(__name__)
).Procfile
to define how the app is run (example: web: uvicorn app:app --host=0.0.0.0 --port=8000
for FastAPI).Click on “New Project” in the PyLex dashboard. Choose your GitHub repo and specify the runtime (e.g., Python 3.10).
PyLex will automatically install the dependencies and run your app. You will receive a public URL once the build is complete.
Any changes you push to GitHub will be automatically deployed.
from flask import Flask app = Flask(__name__) @app.route("/") def home(): return "Hello from PyLex!"
PythonAnywhere is an online IDE and hosting service that supports Python web apps. It’s ideal for small apps and educational projects.
Register for a free account at pythonanywhere.com.
You can upload your files via the web interface or clone your GitHub repo using the Bash console:
git clone https://github.com/your-username/your-repo.git
Open the Bash console and install packages with pip:
pip install --user -r requirements.txt
Go to the “Web” tab and click “Add a new web app.” Choose:
Open the WSGI config file (linked in the web app settings) and point it to your app. Example for Flask:
import sys path = '/home/yourusername/yourproject' if path not in sys.path: sys.path.insert(0, path) from app import app as application
Click “Reload” in the Web tab to start the app. Your public link will look like yourusername.pythonanywhere.com
.
from flask import Flask app = Flask(__name__) @app.route("/") def home(): return "Hello from PythonAnywhere!"