Spaces:
Running
Running
Download pages/api/upload-rules.js from powerllm/anycoder-cf48624d: direct link, hf CLI and curl.
- Browser
- Download file 820 Bytes
-
https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/pages/api/upload-rules.js
- Command line
-
hf download hf://spaces/powerllm/anycoder-cf48624d/pages/api/upload-rules.js
-
curl -L -o upload-rules.js https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/pages/api/upload-rules.js
820 Bytes
| export default function handler(req, res) { | |
| if (req.method === 'POST') { | |
| const { rules } = req.body | |
| if (!Array.isArray(rules)) { | |
| return res.status(400).json({ error: 'Rules must be an array' }) | |
| } | |
| // Validate rules | |
| for (let i = 0; i < rules.length; i++) { | |
| const rule = rules[i] | |
| if (!rule.rule || !rule.condition || !rule.action) { | |
| return res.status(400).json({ | |
| error: `Rule ${i + 1} missing required fields` | |
| }) | |
| } | |
| } | |
| // In production, you would save to database or file system | |
| // For demo, we just return success | |
| return res.status(200).json({ | |
| success: true, | |
| count: rules.length, | |
| message: 'Rules validated successfully' | |
| }) | |
| } | |
| return res.status(405).json({ error: 'Method not allowed' }) | |
| } |