Spaces:
Running
Running
| title: MOFH API Proxy | |
| emoji: π | |
| colorFrom: blue | |
| colorTo: green | |
| sdk: docker | |
| sdk_version: "4.36.0" | |
| python_version: "3.11" | |
| app_file: app.py | |
| pinned: false | |
| # π IONA AI + MOFH API Proxy | |
| **Intelligent Website Generator & MyOwnFreeHost API Proxy** | |
| --- | |
| ## β¨ Features | |
| - π€ **AI Website Generation** - Generate complete websites with HTML, CSS, JS, and MySQL | |
| - π **MOFH Integration** - Create free hosting accounts via API | |
| - π **Beautiful Dashboard** - Real-time system monitoring with uptime display | |
| - π **External IP Display** - Easy MOFH whitelist configuration | |
| - π₯ **Health Checks** - Monitor system health and performance | |
| - π§ͺ **Test Endpoints** - Verify AI functionality before use | |
| --- | |
| ## π― Quick Start | |
| ### 1. Visit Dashboard | |
| ``` | |
| https://your-space.hf.space/ | |
| ``` | |
| ### 2. Copy External IP | |
| - Displayed prominently on dashboard | |
| - Add to MOFH API whitelist | |
| ### 3. Test AI | |
| ``` | |
| https://your-space.hf.space/test | |
| ``` | |
| ### 4. Generate Website | |
| ```bash | |
| curl -X POST https://your-space.hf.space/generate-website \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "prompt": "Create a modern portfolio website", | |
| "business_type": "portfolio", | |
| "color_scheme": "modern" | |
| }' | |
| ``` | |
| --- | |
| ## π‘ API Endpoints | |
| | Method | Endpoint | Description | | |
| |--------|----------|-------------| | |
| | GET | `/` | System dashboard (HTML) | | |
| | GET | `/health` | Health check (JSON) | | |
| | GET | `/test` | Test AI generation | | |
| | POST | `/generate-website` | Generate website with AI | | |
| | POST | `/create` | Create MOFH hosting account | | |
| --- | |
| ## π§ Configuration | |
| ### Environment Variables | |
| - `GROQ_API_KEYS` - Groq AI API keys (4 keys for load balancing) | |
| - `MOFH_API_USERNAME` - MOFH API username | |
| - `MOFH_API_PASSWORD` - MOFH API password | |
| ### AI Models (2026) | |
| - `llama-3.1-8b-instant` - Fastest (131K context) | |
| - `llama-3.3-70b-versatile` - Best quality | |
| - `qwen/qwen3-32b` - Large output (40K tokens) | |
| - `meta-llama/llama-4-scout-17b-16e-instruct` - New Llama 4 | |
| --- | |
| ## π Dashboard Features | |
| - β±οΈ **Uptime Tracking** - Running since, uptime duration | |
| - π **Network Info** - Hostname, local IP, external IP | |
| - π» **System Resources** - CPU usage, memory usage with progress bars | |
| - π€ **AI Configuration** - Active models, API keys, request counts | |
| - π **Request Statistics** - Total, generate, create, errors | |
| - π **Auto-Refresh** - Updates every 30 seconds | |
| --- | |
| ## π§ͺ Testing | |
| ### Health Check | |
| ```bash | |
| curl https://your-space.hf.space/health | |
| ``` | |
| ### AI Test | |
| ```bash | |
| curl https://your-space.hf.space/test | |
| ``` | |
| ### Generate Website | |
| ```bash | |
| curl -X POST https://your-space.hf.space/generate-website \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "prompt": "Create a simple landing page for a tech startup", | |
| "business_type": "landing", | |
| "color_scheme": "modern", | |
| "include_database": false, | |
| "features": ["contact_form", "testimonials"] | |
| }' | |
| ``` | |
| --- | |
| ## π Response Format | |
| ### Success Response | |
| ```json | |
| { | |
| "success": true, | |
| "model_used": "llama-3.3-70b-versatile", | |
| "files": { | |
| "html": "<!DOCTYPE html>...", | |
| "css": "body { ... }", | |
| "js": "console.log('...');", | |
| "sql": "CREATE TABLE...", | |
| "config": "<?php...", | |
| "readme": "# Setup Guide..." | |
| }, | |
| "tokens_used": { | |
| "prompt_tokens": 1234, | |
| "completion_tokens": 5678 | |
| }, | |
| "generation_time": 1234567890 | |
| } | |
| ``` | |
| ### Error Response | |
| ```json | |
| { | |
| "detail": "Error message here" | |
| } | |
| ``` | |
| --- | |
| ## π Security | |
| - β Input validation (Pydantic) | |
| - β Prompt length limits (10-10000 chars) | |
| - β Username validation (3-20 chars) | |
| - β Email format validation | |
| - β Error handling and logging | |
| - β Request tracking | |
| --- | |
| ## π Monitoring | |
| ### Dashboard Metrics | |
| - Uptime duration | |
| - Total requests | |
| - Error count | |
| - CPU usage | |
| - Memory usage | |
| - API key usage | |
| ### Health Endpoint | |
| ```json | |
| { | |
| "status": "healthy", | |
| "uptime_seconds": 12345, | |
| "timestamp": "2026-01-15T10:30:00", | |
| "requests": { | |
| "total": 150, | |
| "generate": 100, | |
| "create": 45, | |
| "errors": 5 | |
| } | |
| } | |
| ``` | |
| --- | |
| ## π οΈ Development | |
| ### Install Dependencies | |
| ```bash | |
| pip install -r requirements.txt | |
| ``` | |
| ### Run Locally | |
| ```bash | |
| uvicorn app:app --host 0.0.0.0 --port 7860 --reload | |
| ``` | |
| ### Deploy to HF Space | |
| 1. Create new Space on Hugging Face | |
| 2. Upload `app.py` and `requirements.txt` | |
| 3. Set Space SDK to "Docker" or "Gradio" | |
| 4. Space will auto-deploy | |
| --- | |
| ## π¨βπ» Developer | |
| **Pratyush Srivastava** | |
| - GitHub: [@pratyush](https://github.com/pratyush) | |
| - Portfolio: [pratyush.dev](https://pratyush.dev) | |
| --- | |
| ## π License | |
| MIT License - Feel free to use and modify | |
| --- | |
| ## π Version | |
| **2026.1.0** - Enhanced with uptime dashboard, external IP display, and comprehensive monitoring | |
| --- | |
| **Status**: β Production Ready (Updated 2026-03-30) | |