voice-detection-api / deployment.md
bakshia's picture
Cleanup: Remove debug prints, improve logging, and refactor comments
476d044

🌍 Deployment Guide: Exposing Your API

Since you have the code running locally on your machine, the fastest way to make it accessible to the world (and link it to your domain) is using a Tunnel.

Option A: Cloudflare Tunnel (Recommended for Custom Domains)

This is free, secure, and allows you to use your own domain (e.g., api.yourdomain.com).

1. Install Cloudflare Tunnel (cloudflared)

Run this in PowerShell to download the verified Windows executable:

# Create a folder for tools
mkdir c:\tools
cd c:\tools

# Download cloudflared
Invoke-WebRequest -Uri https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe -OutFile cloudflared.exe

2. Login to Cloudflare

This connects your machine to your Cloudflare account (where your domain is managed).

.\cloudflared.exe tunnel login
  • A browser window will open. Select the domain you want to use.

3. Create a Tunnel

.\cloudflared.exe tunnel create voice-api
  • Copy the Tunnel ID (a long UUID like d4c3b2a1-...) from the output.

4. Route Your Domain to Localhost

Replace <UUID> with your Tunnel ID and api.yourdomain.com with your desired domain.

# 1. Configure the tunnel target
# Create a config.yml file
echo "url: http://localhost:8000" > config.yml
echo "tunnel: <UUID>" >> config.yml
echo "credentials-file: C:\Users\baksh\.cloudflared\<UUID>.json" >> config.yml

# 2. Assign the domain DNS
.\cloudflared.exe tunnel route dns voice-api api.yourdomain.com

5. Run it!

.\cloudflared.exe tunnel run voice-api

Success! Your local server (localhost:8000) is now live at https://api.yourdomain.com.


Option B: Ngrok (Fastest, Random URL)

If you don't use Cloudflare for DNS, or just want a quick link:

  1. Download Ngrok: https://ngrok.com/download
  2. Run:
    ngrok http 8000
    
  3. Result: It will give you a URL like https://a1b2-c3d4.ngrok-free.app. Use this in the endpoint tester.

πŸ”’ Important: Update Test Scripts

Once you have your public URL, test it using the verify script:

# Update verify_tester_config.py
API_URL = "https://api.yourdomain.com/api/v1/detect"