Takk

Deploy

FastAPI

This guide walks you through deploying a FastAPI application on Takk. FastAPI is a modern, high-performance Python web framework for building APIs. Takk has first-class support for FastAPI, making deployment as simple as defining your app and running a single command.

Prerequisites

Make sure you have the Takk CLI installed and are logged in. If not, follow the Get Started guide first.

Create the Project

Start by creating a new directory and initializing it with uv:

bash
mkdir fastapi-hello
cd fastapi-hello
uv init

Then add your dependencies:

bash
uv add fastapi takk

Write the Application

Create app.py with a minimal FastAPI application:

python
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def hello():
    return {"message": "Hello, World!"}

@app.get("/greet/{name}")
def greet(name: str):
    return {"message": f"Hello, {name}!"}

Define the Project

Create project.py to tell Takk how to run your application:

python
from takk.models import Project, FastAPIApp

project = Project(
    name="fastapi-hello",
    server=FastAPIApp(),
)

Takk automatically discovers your FastAPI app, configures the server, and handles networking, TLS, and health checks for you.

Run Locally

Start the local development environment:

bash
uv run takk up

Your API is now running at http://localhost:8000. Visit it in your browser or test with curl:

bash
curl http://localhost:8000
# {"message": "Hello, World!"}

curl http://localhost:8000/greet/Alice
# {"message": "Hello, Alice!"}

Changes to your code are automatically reloaded while takk up is running.

Deploy

When you're ready to go live, deploy with a single command:

bash
uv run takk deploy

Takk builds a container image, provisions infrastructure, and starts your application in the cloud. No Dockerfiles, no YAML, no infrastructure configuration needed.

Next Steps

Previous
Deploy a Project