| # How to Start the Server | |
| ## The Problem | |
| The "Not Found" error means the server is **not running**. You need to start it first. | |
| ## Solution: Start the Server | |
| ### Step 1: Open a PowerShell Terminal | |
| Make sure you're in the project directory: | |
| ```powershell | |
| cd C:\Users\tarun\IITMTdsPrj2 | |
| ``` | |
| ### Step 2: Set Environment Variables | |
| ```powershell | |
| $env:QUIZ_SECRET = "EasyQuiz" | |
| $env:OPENAI_API_KEY = "eyJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6IjI0ZjIwMDU3NTNAZHMuc3R1ZHkuaWl0bS5hYy5pbiJ9.eji7L5I62M9YHoeEKE8ao6eTw8dFjgDIMP9C3lOUXc4" | |
| ``` | |
| ### Step 3: Start the Server | |
| ```powershell | |
| python -m app.main | |
| ``` | |
| You should see: | |
| ``` | |
| INFO: Started server process [...] | |
| INFO: Waiting for application startup. | |
| INFO: Application startup complete. | |
| INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) | |
| ``` | |
| **Keep this terminal open!** The server runs in this window. | |
| ### Step 4: Test in Another Terminal | |
| Open a **NEW PowerShell window** and run: | |
| ```powershell | |
| # Set variables again (in the new window) | |
| $env:QUIZ_SECRET = "EasyQuiz" | |
| # Test the API | |
| $body = @{ | |
| email = "24f2005753@ds.study.iitm.ac.in" | |
| secret = "EasyQuiz" | |
| url = "https://tds-llm-analysis.s-anand.net/demo" | |
| } | ConvertTo-Json | |
| Invoke-RestMethod -Uri "http://127.0.0.1:8000/demo" -Method POST -ContentType "application/json" -Body $body | |
| ``` | |
| ## Quick Test Script | |
| I've created a test script. After starting the server, run: | |
| ```powershell | |
| .\test_server.ps1 | |
| ``` | |
| This will test all endpoints and show you what's working. | |
| ## Troubleshooting | |
| ### "Module not found" error | |
| ```powershell | |
| pip install -r requirements.txt | |
| ``` | |
| ### "Port already in use" error | |
| Another process is using port 8000. Either: | |
| - Stop the other process | |
| - Change the port: `$env:PORT = "8001"` then restart | |
| ### Server starts but endpoints don't work | |
| - Make sure you're using the correct URL: `http://127.0.0.1:8000` or `http://localhost:8000` | |
| - Check for errors in the server terminal | |
| - Restart the server after code changes | |
| ## Summary | |
| 1. ✅ Start server: `python -m app.main` (keep terminal open) | |
| 2. ✅ Open new terminal for testing | |
| 3. ✅ Set variables in new terminal | |
| 4. ✅ Test API endpoints | |