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.
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
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 26.4MB
glibcpy 3.10–3.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)
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.