--- title: Web Search Worker emoji: 🔍 colorFrom: blue colorTo: green sdk: docker sdk_version: "latest" app_file: app.py pinned: false --- # Web Scraping Worker for HuggingFace Spaces A web scraping project with a FastAPI worker backend and a simple Express frontend. ## Components 1. **FastAPI Worker** - Processes search queries and returns results 2. **Express Frontend** - Simple web interface to interact with the worker ## Local Setup ### FastAPI Worker ```bash # Create virtual environment python -m venv venv # Activate virtual environment source venv/bin/activate # On Linux/Mac # or venv\Scripts\activate # On Windows # Install dependencies pip install -r requirements.txt # Run the server python app.py ``` The FastAPI worker will be available at `http://localhost:8000` ### Express Frontend ```bash # Install dependencies npm install # Run the server node server.js ``` The frontend will be available at `http://localhost:3000` ## HuggingFace Spaces Deployment 1. Create a new Docker Space on HuggingFace 2. Upload the following files: - `app.py` - `requirements.txt` - `Dockerfile` 3. Deploy the Space ## API Usage ### Search Endpoint ```bash curl -X POST https://[your-space-name].hf.space/search -H "Content-Type: application/json" -d '{"query":"your search query", "num_results": 10}' ``` ## Connecting Frontend to Deployed Worker Once the worker is deployed to HuggingFace Spaces, update the `apiUrl` in the frontend code (server.js) to point to your deployed worker URL.