forked from princeixr/Multi-Agent-Financial-Complaint-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev_https.sh
More file actions
executable file
·53 lines (44 loc) · 1.43 KB
/
dev_https.sh
File metadata and controls
executable file
·53 lines (44 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
# Run the FastAPI app over HTTPS for local development (trusted cert via mkcert).
#
# One-time setup (from repo root):
# brew install mkcert
# mkcert -install
# mkdir -p .certs && cd .certs && mkcert localhost 127.0.0.1 ::1 && cd -
#
# Then open: https://127.0.0.1:8001 (or the port you set)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$ROOT"
HOST="${HOST:-0.0.0.0}"
PORT="${PORT:-8001}"
CERT_DIR="$ROOT/.certs"
if [[ ! -d "$CERT_DIR" ]]; then
echo "Missing $CERT_DIR"
echo "Create certificates first:"
echo " brew install mkcert && mkcert -install"
echo " mkdir -p .certs && cd .certs && mkcert localhost 127.0.0.1 ::1"
exit 1
fi
# mkcert produces e.g. localhost+2.pem and localhost+2-key.pem
CERT="$(find "$CERT_DIR" -maxdepth 1 -name '*.pem' ! -name '*-key.pem' 2>/dev/null | head -1)"
if [[ -z "${CERT}" || ! -f "$CERT" ]]; then
echo "No certificate (*.pem except *-key.pem) found in $CERT_DIR"
echo "Run: cd .certs && mkcert localhost 127.0.0.1 ::1"
exit 1
fi
BASE="${CERT%.pem}"
KEY="${BASE}-key.pem"
if [[ ! -f "$KEY" ]]; then
echo "Missing private key: $KEY"
exit 1
fi
PY="$ROOT/.venv/bin/python3"
if [[ ! -x "$PY" ]]; then
PY="python3"
fi
echo "Starting https://127.0.0.1:${PORT} (bind ${HOST}:${PORT})"
exec "$PY" -m uvicorn main:app --reload --host "$HOST" --port "$PORT" \
--ssl-keyfile "$KEY" \
--ssl-certfile "$CERT"