Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.11-slim

# Set working directory
WORKDIR /opt/code/

# Copy files into the image
COPY . /opt/code/

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fastapi
uvicorn
python-dotenv
24 changes: 24 additions & 0 deletions example_dropin_environments/fast_api_example/model/start_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
from fastapi import FastAPI
from fastapi.responses import JSONResponse

# Get the URL prefix from environment
url_prefix = os.getenv("URL_PREFIX", "")

# Initialize the FastAPI app
app = FastAPI()

# Mount routes under the prefix using an APIRouter
from fastapi import APIRouter
router = APIRouter()

@router.get("/")
async def root():
return JSONResponse(status_code=200, content={"message": "OK"})

@router.post("/test")
async def test():
return {"result": "passed"}

# Include router with URL prefix
app.include_router(router, prefix=url_prefix)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# Launch the FastAPI app on port 8080
exec uvicorn start_app:app --host 0.0.0.0 --port 8080 --app-dir /opt/code/