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
Empty file added app/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from fastapi import FastAPI

app = FastAPI(title="FastAPI Server")


@app.get("/")
def read_root():
return {"status": "ok"}
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fastapi
uvicorn[standard]
35 changes: 35 additions & 0 deletions scripts/start-fastapi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -euo pipefail

# Usage: ./scripts/start-fastapi.sh [--host 0.0.0.0] [--port 8000] [--reload]
# Requires: uvicorn (pip install uvicorn[standard]) and fastapi

HOST="127.0.0.1"
PORT="8000"
RELOAD=""

while [[ $# -gt 0 ]]; do
case $1 in
--host)
HOST="$2"; shift 2 ;;
--port)
PORT="$2"; shift 2 ;;
--reload)
RELOAD="--reload"; shift ;;
*)
echo "Unknown argument: $1" >&2; exit 1 ;;
esac
done

# Detect available Python interpreter
if command -v python3 >/dev/null 2>&1; then
PYTHON_BIN="python3"
elif command -v python >/dev/null 2>&1; then
PYTHON_BIN="python"
else
echo "Python interpreter not found. Please install Python 3." >&2
exit 127
fi

# Prefer invoking uvicorn as a module to avoid PATH issues
exec "$PYTHON_BIN" -m uvicorn app.main:app --host "$HOST" --port "$PORT" $RELOAD