Registry / web-framework / flask-cloudflared

flask-cloudflared

JSON →
library0.0.15pypypi✓ verified 33d ago

Flask-Cloudflared (current version 0.0.15) is a Python library designed to effortlessly start a TryCloudflare Tunnel directly from your Flask application. It simplifies exposing your local development server to the internet via Cloudflare Tunnels, making it ideal for webhook testing, demos, or sharing progress without complex port forwarding. The library is actively maintained, with new patch versions released as needed.

web-frameworkdevops
Install & Compatibility
Where this runs
tested against v0.0.15 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 26.4MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.1s · import 0.000s · 27MB
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from flask_cloudflared import run_with_cloudflared
from flask_cloudflared import get_cloudflared_url
from flask_cloudflared import cleanup_cloudflared

This quickstart demonstrates how to initialize a basic Flask application and start a Cloudflare Tunnel to expose it. The `run_cloudflared_tunnel` function handles the tunnel creation and outputs the public URL. Ensure Flask is running on the port specified for the tunnel.

import os from flask import Flask from flask_cloudflared import run_cloudflared_tunnel app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, World!' if __name__ == '__main__': # Cloudflared will attempt to expose the specified port (default Flask port is 5000) # The tunnel runs in a separate process, allowing app.run() to proceed. tunnel_url = run_cloudflared_tunnel(port=5000) if tunnel_url: print(f"Cloudflare Tunnel is active at: {tunnel_url}") else: print("Failed to start Cloudflare Tunnel.") # Run the Flask application on the same port app.run(port=5000)
Debug
Known footguns
gotchaThe `cloudflared` executable must be present and accessible in your system's PATH. Although `pip install cloudflared` helps, it doesn't always guarantee immediate accessibility in all environments, especially if relying on system-wide PATH configurations.
gotchaThe `run_cloudflared_tunnel` function is non-blocking, meaning it starts the tunnel in a separate subprocess. Ensure your Flask app starts *after* calling `run_cloudflared_tunnel` (as shown in quickstart) and on the same port, otherwise the tunnel might try to connect to a non-existent or wrong service.
gotchaAs a 0.0.x version library, `flask-cloudflared`'s API is subject to change without strict adherence to semantic versioning. While stable for its current features, expect potential minor breaking changes in future `0.0.y` releases.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
11 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
Resources