Nesakan/sastra-captcha
0
SASTRA CAPTCHA Proxy Service
A lightweight Express.js service that fetches CAPTCHA images from the SASTRA webstream portal using Puppeteer.
Endpoints
Response Headers
The /captcha endpoint returns:
Content-Type: image/pngx-session-id: The JSESSIONID cookie needed for subsequent login requests
🚀 EXACT DEPLOYMENT STEPS
Follow these steps exactly to deploy to Hugging Face Spaces:
Step 1: Create a Hugging Face Account (if you don't have one)
- Go to huggingface.co
- Click Sign Up in the top right
- Create your account and verify your email
Step 2: Create a New Space
- Go to huggingface.co/new-space
- Fill in the form:
- Owner: Select your username
- Space name:
sastra-captcha(or any name you prefer) - License: MIT (or your preference)
- SDK: Select Docker ⚠️ IMPORTANT!
- Hardware: Select CPU basic (free tier: 2 vCPU, 16GB RAM)
- Visibility: Public or Private (your choice)
- Click Create Space
Step 3: Clone the Space Repository
After creating the space, you'll see instructions. Run these commands in your terminal:
# Navigate to your project folder
cd d:\Projects\SastraWeb\hf-captcha
# Initialize git if not already
git init
# Add Hugging Face remote (replace Nesakan with your HF username)
git remote add origin https://huggingface.co/spaces/Nesakan/sastra-captcha
# OR if you already have a remote, set it:
git remote set-url origin https://huggingface.co/spaces/Nesakan/sastra-captchaStep 4: Push Your Code
# Stage all files
git add .
# Commit
git commit -m "Initial deployment"
# Push to Hugging Face (you'll be prompted for your HF credentials)
git push -u origin mainNote: If prompted for credentials, use: - Username: Your Hugging Face username - Password: Your Hugging Face Access Token (create one at Settings > Access Tokens)
Step 5: Wait for Build
- Go to your Space page:
https://huggingface.co/spaces/Nesakan/sastra-captcha - Click on the "Logs" tab to watch the build progress
- Wait for the container to build and start (usually 2-5 minutes)
- The status will change from "Building" to "Running"
Step 6: Test Your Service
Once running, your service will be available at:
https://Nesakan-sastra-captcha.hf.spaceTest the endpoints:
- Health Check:
https://Nesakan-sastra-captcha.hf.space/ - CAPTCHA:
https://Nesakan-sastra-captcha.hf.space/captcha
Step 7: Update Your Frontend
Update your SASTRAWeb frontend to use the new URL. Find wherever your frontend calls the captcha API and change:
Old (Railway):
const response = await fetch('https://your-railway-url.railway.app/captcha');New (Hugging Face):
const response = await fetch('https://Nesakan-sastra-captcha.hf.space/captcha');Troubleshooting
Build Fails
- Check the Logs tab for error messages
- Ensure all files are committed and pushed
CAPTCHA Returns 503
- The SASTRA portal might be temporarily unavailable
- Check the Logs for detailed error messages
Slow Cold Start
- First request after inactivity may take 10-30 seconds (this is normal for free tier)
- Subsequent requests will be much faster
Local Testing (Optional)
If you have Docker installed locally, you can test before deploying:
cd d:\Projects\SastraWeb\hf-captcha
docker build -t sastra-captcha .
docker run -p 7860:7860 sastra-captchaThen open http://localhost:7860/captcha in your browser.
