{"id":29038196,"url":"https://github.com/0xtbug/calories-prediction-api","last_synced_at":"2025-06-26T13:37:00.247Z","repository":{"id":299601303,"uuid":"1003478956","full_name":"0xtbug/Calories-Prediction-API","owner":"0xtbug","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-17T10:18:48.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-17T11:29:12.798Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xtbug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-17T07:59:21.000Z","updated_at":"2025-06-17T10:18:51.000Z","dependencies_parsed_at":"2025-06-17T11:31:34.565Z","dependency_job_id":"4ee81645-4e5e-470d-a4e7-cf1dad66929c","html_url":"https://github.com/0xtbug/Calories-Prediction-API","commit_stats":null,"previous_names":["0xtbug/calories-prediction-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/0xtbug/Calories-Prediction-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xtbug%2FCalories-Prediction-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xtbug%2FCalories-Prediction-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xtbug%2FCalories-Prediction-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xtbug%2FCalories-Prediction-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xtbug","download_url":"https://codeload.github.com/0xtbug/Calories-Prediction-API/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xtbug%2FCalories-Prediction-API/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262077163,"owners_count":23255132,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-26T13:36:59.175Z","updated_at":"2025-06-26T13:37:00.230Z","avatar_url":"https://github.com/0xtbug.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Calories Prediction API Deployment Guide\n\n## Directory Structure\n```\ncalories-api/\n├── app.py\n├── wsgi.py\n├── requirements.txt\n├── README.md\n└── model/\n    └── Calories_Prediction_model.pkl\n```\n\n## PythonAnywhere Deployment Steps\n\n1. Sign up for a PythonAnywhere account at https://www.pythonanywhere.com/\n\n2. Upload your files:\n   - Go to the Files tab\n   - Create a new directory (e.g., `calories-api`)\n   - Create a subdirectory called `model`\n   - Upload these files:\n     - `app.py` → calories-api/\n     - `wsgi.py` → calories-api/\n     - `requirements.txt` → calories-api/\n     - `Calories_Prediction_model.pkl` → calories-api/model/\n\n3. Set up a virtual environment:\n   ```bash\n   # In PythonAnywhere bash console\n   cd calories-api\n   python -m venv venv\n   source venv/bin/activate\n   pip install -r requirements.txt\n   ```\n\n4. Configure the web app:\n   - Go to the Web tab\n   - Click \"Add a new web app\"\n   - Choose \"Manual configuration\"\n   - Select Python version (3.8 or higher)\n   - Set the following configurations:\n     - Source code: /home/YOUR_USERNAME/calories-api\n     - Working directory: /home/YOUR_USERNAME/calories-api\n     - WSGI configuration file: /var/www/YOUR_USERNAME_pythonanywhere_com_wsgi.py\n\n5. Update the WSGI configuration:\n   - In the Web tab, click on the WSGI configuration file link\n   - Replace the content with:\n     ```python\n     import sys\n     import os\n     \n     # Add your project directory to the sys.path\n     path = '/home/YOUR_USERNAME/calories-api'\n     if path not in sys.path:\n         sys.path.append(path)\n     \n     from wsgi import application\n     ```\n\n6. Configure static files (if needed):\n   - In the Web tab, add any static file mappings\n   - URL: /static/\n   - Directory: /home/YOUR_USERNAME/calories-api/static\n\n7. Enable CORS:\n   - The app already has CORS enabled for all origins\n   - If you need to restrict it, modify the CORS settings in app.py\n\n8. Check file permissions:\n   ```bash\n   # In PythonAnywhere bash console\n   cd calories-api\n   chmod 755 .\n   chmod 755 model\n   chmod 644 model/Calories_Prediction_model.pkl\n   ```\n\n9. Reload the web app:\n   - Click the \"Reload\" button in the Web tab\n\n## Testing the Deployed API\n\nTest your API using curl:\n```bash\ncurl -X POST https://YOUR_USERNAME.pythonanywhere.com/predict \\\n     -H \"Content-Type: application/json\" \\\n     -d '{\n         \"Age\": 25,\n         \"Height\": 170,\n         \"Weight\": 65,\n         \"Duration\": 30,\n         \"Heart_Rate\": 80,\n         \"Body_Temp\": 37,\n         \"Gender\": 1\n     }'\n```\n\n## Frontend Configuration\n\nUpdate your frontend Vite configuration to point to the production API:\n\n```typescript\n// vite.config.ts\nexport default defineConfig({\n  // ... other config\n  server: {\n    proxy: {\n      '/api': {\n        target: 'https://YOUR_USERNAME.pythonanywhere.com',\n        changeOrigin: true,\n        rewrite: (path) =\u003e path.replace(/^\\/api/, '')\n      }\n    }\n  }\n});\n```\n\n## Troubleshooting\n\n1. If you see \"Internal Server Error\":\n   - Check the error logs in the Web tab\n   - Verify all required files are uploaded\n   - Check the virtual environment has all dependencies\n   - Verify the model file is in the correct location (model/Calories_Prediction_model.pkl)\n\n2. If you see CORS errors:\n   - Verify the frontend URL is making requests to the correct endpoint\n   - Check the Network tab in browser dev tools for the actual request URL\n\n3. If the model fails to load:\n   - Check the file permissions of the model file and directories\n   - Verify the model file was uploaded to the correct location\n   - Check the error logs for specific error messages\n\n4. Common issues:\n   - Model file not found: Make sure it's in the `model` directory\n   - Permission denied: Run the chmod commands in step 8\n   - Import errors: Make sure all requirements are installed in the virtual environment ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xtbug%2Fcalories-prediction-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xtbug%2Fcalories-prediction-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xtbug%2Fcalories-prediction-api/lists"}