Host applications from old PCs using Cloudflare Tunnels
Project description
Hostify - Host from Anywhere
Turn old PCs into production servers with one line of code.
Host applications from old PCs or home machines using Cloudflare Tunnels. No port forwarding, no dynamic DNS, just pure simplicity.
๐ Quick Start
from hostify import Host
# Host your app in one line
Host(domain="app.example.com", port=3000).serve()
That's it! Your app is now live at https://app.example.com with automatic HTTPS.
๐ฆ Installation
pip install hostify
Requirements:
- Python >= 3.9
- Cloudflare account with a domain
- Cloudflare API token (setup guide)
๐ฏ Features
- โ One-line API - Simple and intuitive
- โ Automatic HTTPS - Secure by default via Cloudflare
- โ No Port Forwarding - Works behind NAT/firewalls
- โ Cross-Platform - Windows, Linux, macOS
- โ Static Files - Built-in HTTP server
- โ Existing Servers - Works with Flask, Node, PHP, etc.
- โ Auto-Cleanup - Graceful shutdown with Ctrl+C
- โ Auto-Recovery - Restarts on connection issues
๐ก Use Cases
- Development - Share local dev server with team
- Demos - Show clients your work without deployment
- Old Hardware - Turn old PCs into production servers
- Home Labs - Host personal projects from home
- Testing - Test webhooks and integrations locally
๐ Usage Examples
Example 1: Host Static Files
from hostify import Host
# Serve static HTML/CSS/JS files
Host(
domain="mysite.example.com",
path="./public"
).serve()
Example 2: Host Flask App
from flask import Flask
from hostify import Host
app = Flask(__name__)
@app.route('/')
def home():
return "<h1>Hello World!</h1>"
if __name__ == '__main__':
# Start Flask in background
import threading
threading.Thread(target=lambda: app.run(port=5000)).start()
# Host it with hostify
Host(domain="flask.example.com", port=5000).serve()
Example 3: Host Existing Server
from hostify import Host
# Your Node.js/PHP/Python server is already running on port 3000
Host(domain="app.example.com", port=3000).serve()
Example 4: Custom API Token
from hostify import Host
Host(
domain="app.example.com",
port=8000,
api_token="your_cloudflare_api_token"
).serve()
๐ง Setup Guide
Step 1: Install Hostify
pip install hostify
Step 2: Get Cloudflare API Token
- Go to Cloudflare API Tokens
- Click "Create Token"
- Use "Edit Cloudflare Zero Trust" template or create custom token with:
- Account โ Cloudflare Tunnel โ Edit
- Zone โ DNS โ Edit
- Zone โ Zone โ Read
- Copy the token
Detailed guide: CLOUDFLARE_SETUP.md
Step 3: Set Environment Variable
Windows (PowerShell):
$env:CF_API_TOKEN="your_token_here"
Linux/Mac:
export CF_API_TOKEN="your_token_here"
Permanent (add to profile):
# Linux/Mac: Add to ~/.bashrc or ~/.zshrc
echo 'export CF_API_TOKEN="your_token_here"' >> ~/.bashrc
# Windows: Use System Environment Variables
setx CF_API_TOKEN "your_token_here"
Step 4: Add Domain to Cloudflare
Make sure your domain is added to Cloudflare and nameservers are configured.
Step 5: Run Hostify
from hostify import Host
Host(domain="app.yourdomain.com", port=3000).serve()
๐จ Live Demos
Check out these live examples hosted with hostify:
- Static Site: https://hostify.yaspik.tech
- Flask App: https://app.yaspik.tech
๐ API Reference
Host Class
Host(
domain: str, # Required: Full domain (e.g., "app.example.com")
port: int = None, # Port of existing server (mutually exclusive with path)
path: str = None, # Path to static files (mutually exclusive with port)
api_token: str = None # Optional: Cloudflare API token
)
Methods:
.serve()- Start hosting (blocks until Ctrl+C)
Parameters:
- domain (required): Full domain or subdomain (e.g., "app.example.com")
- port (optional): Port number where your app is running (1-65535)
- path (optional): Path to directory with static files
- api_token (optional): Cloudflare API token (defaults to
CF_API_TOKENenv var)
Note: You must specify either port OR path, not both.
๐ How It Works
- Creates Cloudflare Tunnel - Establishes secure connection
- Configures DNS - Automatically creates CNAME record
- Routes Traffic - Configures tunnel to route domain to your local server
- Manages Binary - Downloads and runs cloudflared automatically
- Monitors Connection - Auto-restarts on failures
- Cleans Up - Removes all resources on Ctrl+C
๐ ๏ธ Troubleshooting
"No server found on port X"
Solution: Make sure your application is running before starting hostify.
# Terminal 1: Start your app
python app.py
# Terminal 2: Host it
python host.py
"Zone not found for domain"
Solution: Ensure your domain is added to Cloudflare and nameservers are configured.
"No Cloudflare accounts found"
Solution: Check your API token has the correct permissions:
- Account โ Cloudflare Tunnel โ Edit
- Zone โ DNS โ Edit
- Zone โ Zone โ Read
Site shows 404
Solution: Wait 30-60 seconds for tunnel to fully connect and DNS to propagate.
"Cloudflare API token not found"
Solution: Set the CF_API_TOKEN environment variable or pass api_token parameter.
๐งช Testing
Run the comprehensive test suite:
python tests/test_suite.py
Expected output:
Results: 9/9 tests passed (100%)
All tests passed! Library is ready for publication.
๐ Project Structure
hostify/
โโโ hostify/ # Main package
โ โโโ __init__.py # Package exports
โ โโโ cloudflare.py # Cloudflare API wrapper
โ โโโ cloudflared.py # Binary manager
โ โโโ host.py # Main Host class
โ โโโ utils.py # Utilities
โโโ examples/ # Usage examples
โโโ tests/ # Test suite
โโโ docs/ # Documentation
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built on Cloudflare Tunnels
- Inspired by the need for simple, accessible hosting solutions
๐ Support
- Documentation: Full Docs
- Issues: GitHub Issues
- Cloudflare Setup: Setup Guide
๐ฎ Roadmap
- Multiple domain support
- Web dashboard for management
- Authentication system
- Custom cloudflared configuration
- Load balancing
- Health checks and monitoring
- CLI tool
Made with โค๏ธ for developers who want to host from anywhere
โญ Star History
If you find this project useful, please consider giving it a star on GitHub!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hostify-0.1.1.tar.gz.
File metadata
- Download URL: hostify-0.1.1.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e0ce5520d1e5ac3cdbfac009faf2124aa65ef40b14605a743246b2b22be29df
|
|
| MD5 |
6635df264a1a4ea3397c3031f94357b5
|
|
| BLAKE2b-256 |
d907334078718c4bed0cf211b1a5d85c84dd0ce334be0b6ed30a8a5febd72a37
|
File details
Details for the file hostify-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hostify-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5839e31d3a393f4c82c5b78f0f7ac160e0e807d05db5003ddb9be585e60e25a
|
|
| MD5 |
28ed26c57602b5401e9afa55e62b3b75
|
|
| BLAKE2b-256 |
b721a9f143d3ba34b8d8ae2ba0f69df33815100b838b1f4317cefd44c82902f2
|