metadata
title: Cloudflare Manager
emoji: βοΈ
colorFrom: orange
colorTo: yellow
sdk: gradio
sdk_version: 4.0.0
app_file: app.py
pinned: false
license: mit
Cloudflare Multi-Account Manager
π A comprehensive web interface for managing Cloudflare Pages, Domains, and Workers.
Features
β Pages Management
- Create and deploy Pages projects
- List all projects
- View deployment URLs
β Domain & Nameservers
- Create DNS zones
- Get nameservers for domain registrars
- Bind custom domains to Pages projects
β Worker Routes
- Configure worker routes
- Add custom domains to workers
- Manage route patterns
Quick Start
Using the Web Interface
- Enter your Cloudflare Email and API Token
- Click "Test Connection" to verify
- Use the tabs to manage your resources
Getting Your API Token
- Go to https://dash.cloudflare.com/profile/api-tokens
- Create a new token with these permissions:
- Account > Cloudflare Pages > Edit
- Zone > DNS > Edit
- Zone > Workers Routes > Edit
- Copy the token and paste it in the interface
Docker Deployment
Build and run with Docker:
# Build the image
docker build -t cloudflare-manager .
# Run the container
docker run -p 7860:7860 cloudflare-manager
Access at: http://localhost:7860
With Environment Variables
docker run -p 7860:7860 \
-e CLOUDFLARE_EMAIL="your-email@example.com" \
-e CLOUDFLARE_TOKEN="your-api-token" \
cloudflare-manager
Hugging Face Spaces Deployment
This app is designed to run on Hugging Face Spaces:
- Create a new Space on Hugging Face
- Select "Gradio" as the SDK
- Upload all files or connect to Git
- The app will automatically deploy
Setting Secrets in Hugging Face
For better security, set your credentials as Secrets:
- Go to your Space settings
- Add secrets:
CLOUDFLARE_EMAIL: Your Cloudflare emailCLOUDFLARE_TOKEN: Your API token
- The app will automatically use these credentials
Local Development
# Install dependencies
pip install -r requirements.txt
# Run the app
python3 app.py
Access at: http://localhost:7860
Python API
You can also use the Python API directly:
from cloudflare_manager import CloudflareManager, CloudflareAccount
# Initialize
account = CloudflareAccount(
email="your-email@example.com",
token="your-api-token"
)
cf = CloudflareManager(account)
# Create Pages project
cf.create_pages_project("my-site", "main")
# Get nameservers
zone = cf.create_zone("example.com")
print(zone["name_servers"])
# Bind domain
cf.add_pages_domain("my-site", "example.com")
CLI Tools
Run interactive commands:
# Quick start wizard
python3 quickstart.py
# Interactive menu
python3 cloudflare_manager.py
# Run examples
python3 example_usage.py
# Run tests
python3 test_manager.py
Project Structure
.
βββ app.py # Gradio web interface
βββ cloudflare_manager.py # Core library
βββ Dockerfile # Docker configuration
βββ requirements.txt # Python dependencies
βββ quickstart.py # CLI quick start
βββ example_usage.py # Usage examples
βββ test_manager.py # Test suite
βββ docs/ # Documentation
βββ README.md
βββ GET_STARTED.md
βββ USAGE_GUIDE.md
βββ API_REFERENCE.md
Documentation
- Quick Start Guide - Get started in 5 minutes
- Usage Guide - Complete usage examples
- API Reference - Full API documentation
- Project Summary - Technical overview
Common Use Cases
1. Deploy a Static Website
# Create project
cf.create_pages_project("my-blog", "main")
# Deploy files
cf.deploy_pages_project("my-blog", "./public", "main")
# Add custom domain
zone = cf.create_zone("myblog.com")
cf.add_pages_domain("my-blog", "myblog.com")
# Get nameservers to set in registrar
print(zone["name_servers"])
2. Configure API Subdomain
# Get zone
zone = cf.get_zone_by_name("example.com")
# Create worker route
cf.create_worker_route(
zone_id=zone["id"],
pattern="example.com/api/*",
script_name="api-worker"
)
# Add custom subdomain
cf.add_worker_domain(
hostname="api.example.com",
service="api-worker",
zone_id=zone["id"]
)
Troubleshooting
API Token Errors
Error: "Invalid request headers"
Solution: Make sure your API token has the correct permissions:
- Account > Cloudflare Pages > Edit
- Zone > DNS > Edit
- Zone > Workers Routes > Edit
Zone Not Found
Error: "Zone not found"
Solution: Create the zone first:
cf.create_zone("example.com")
DNS Propagation
After adding a domain:
- Update nameservers at your registrar
- Wait 5-30 minutes for DNS propagation
- Check status:
cf.get_zone_by_name("example.com")
Security
- Never commit API tokens to Git
- Use environment variables or Hugging Face Secrets
- Rotate tokens regularly
- Use least-privilege permissions
Support
- π Full documentation in the
/docsfolder - π Report issues on GitHub
- π¬ Ask questions in Hugging Face Discussions
License
MIT License - Free to use and modify
Credits
Built with:
- Python 3.10+
- Gradio for the web interface
- Cloudflare API
- Docker for containerization
Version: 1.0.0
Last Updated: 2024-01-27
Status: β
Production Ready