Deploy a FastAPI App on Leapcell
You can deploy a FastAPI Python app on Leapcell in just a few clicks.
This quickstart uses a simple example app. You’re welcome to use your own FastAPI app instead.
1. Fork the FastAPI example on GitHub.
Here’s the app.py
file from that repo, which is borrowed from the official FastAPI docs:
from typing import Union
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
2. Create a Service in the Leapcell Dashboard and connect your new repo.
Go to the Leapcell Dashboard and click the New Service
button.
Then click Connect with GitHub
and select the forked repository.
3. Provide the following values during creation:
We will use uvicorn to run the FastAPI app, so ensure you add uvicorn
to your requirements.txt
.
Below are the basic configuration details for setting up a FastAPI service on Leapcell:
Field | Value |
---|---|
Runtime | Python (Any version) |
Build Command | pip install -r requirements.txt |
Start Command | uvicorn app:app --host 0.0.0.0 --port 8080 |
Port | 8080 |
4. Access Your App:
Once deployed, you should see a URL like foo-bar.leapcell.dev
on the Deployment page. Visit the domain shown on the service page.
Continuous Deployments
Every push to the linked branch automatically triggers a build and deploy. Failed builds are safely canceled, leaving the current version running until the next successful deploy.
Learn more about Continuous Deployments.