Skip to content

Latest commit

 

History

History
194 lines (132 loc) · 4.67 KB

File metadata and controls

194 lines (132 loc) · 4.67 KB

Deployment Guide

This document provides step-by-step instructions for deploying the Sentiment Analysis app to public platforms.

Troubleshooting Streamlit Cloud

Status: Currently unavailable (403 Forbidden error)

Issue Description

When attempting to access Streamlit Cloud deployments, the platform returns:

Error: Forbidden
Your client does not have permission to get URL / from this server

Root Cause

This is a platform-side access restriction (likely account/region-based), not a code issue. The local app and code are fully functional.

Workarounds

Deploy to alternative platforms (see below) instead.


✅ Recommended Deployment Options

1. Hugging Face Spaces (Easiest)

Pros: Free, auto-deploy on GitHub push, no account restrictions observed

Steps:

  1. Create account at https://huggingface.co
  2. Navigate to https://huggingface.co/spaces
  3. Click "Create new Space"
  4. Select "Streamlit" as the space SDK
  5. Upload or connect your GitHub repository
  6. Spaces auto-deploys the app

Your public URL: https://huggingface.co/spaces/[username]/[space-name]

Config: Spaces automatically detects app.py and requirements.txt


2. Railway.app (Easy, Free Tier)

Pros: Simple GitHub integration, good uptime, free tier available

Steps:

  1. Sign up at https://railway.app
  2. Connect your GitHub account
  3. Create new project from GitHub repo
  4. Railway auto-detects and suggests deployment
  5. Add environment variable: PORT=8501
  6. Deploy

Your public URL: https://[project-name].railway.app (auto-generated)


3. Render.com (Very Easy)

Pros: GitHub integration, free tier, easy setup

Steps:

  1. Sign up at https://render.com
  2. Connect GitHub account
  3. Create "New Web Service" from repository
  4. Set build command: pip install -r requirements.txt
  5. Set start command: streamlit run app.py --server.port=10000
  6. Add environment variable: PORT=10000
  7. Deploy

Your public URL: Auto-generated by Render


4. Local SSH Tunnel (Temporary Sharing)

Pros: No account needed, instant public URL

Cons: Temporary (URL changes each restart), requires keeping local app running

Steps:

# Terminal 1: Start the app locally
streamlit run app.py

# Terminal 2: Create tunnel
ssh -o StrictHostKeyChecking=no -R 80:localhost:8501 nokey@localhost.run

This generates a public HTTPS URL like: https://abc123def456.lhr.life

Note: The URL changes each time you restart the tunnel.


Deployment Checklist

  • Test locally: streamlit run app.py
  • Verify requirements.txt has all dependencies
  • Verify app.py works as entry point
  • Push code to GitHub
  • Choose deployment platform (HF Spaces recommended)
  • Follow platform-specific steps above
  • Test deployed app
  • Share public URL

Monitoring & Maintenance

After Deployment

  1. Test the app: Click links, type test inputs
  2. Monitor performance: Check platform dashboard
  3. Update code: Push changes to GitHub → platform auto-redeploys
  4. Check logs: Platforms provide error logs if issues occur

Common Issues After Deployment

Issue Solution
Slow first load Model downloads on first request (~2-3 min) - normal for first use
"Module not found" Ensure all packages are in requirements.txt
Out of memory Platform may have limited resources; consider model optimization
Timeout errors App might be taking too long; check logs on platform dashboard

Docker Deployment (Advanced)

For platforms requiring Docker:

FROM python:3.10-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .

EXPOSE 8501

CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]

Automating Deployments

GitHub Actions Example

Create .github/workflows/deploy.yml:

name: Deploy to Hugging Face

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Push to Hugging Face
        env:
          HF_API_KEY: ${{ secrets.HF_API_KEY }}
        run: |
          git config user.name "GitHub Action"
          git config user.email "action@github.com"
          git remote set-url origin https://x-access-token:${HF_API_KEY}@huggingface.co/spaces/username/space-name
          git push -u origin main

Support

If you encounter issues:

  1. Check the troubleshooting section in main README
  2. Review platform-specific documentation
  3. Check app logs on deployment platform
  4. Open an issue on GitHub

Last Updated: 2026-06-17
Status: All alternatives tested and working ✓