mofh-api-proxy / README.md
mrsavage1's picture
Upload 14 files
90b617f verified
---
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)