Skip to main content

Context manger for Cloudflared

Project description

with-cloudflared

With-cloudflared provides a context manager to start and stop cloudflared. Cloudflare Tunnel provides you with a secure way to connect your resources to Cloudflare without a publicly routable IP address. This is useful for development and testing, as well as for production use cases. See the Cloudflare Tunnel documentation for more information.

Installation

pip install with-cloudflared

Usage

import uvicorn
from fastapi import FastAPI
from with_cloudflared import cloudflared

app = FastAPI()

@app.get("/")
def read_root():
    return {"Hello": "World"}

if __name__ == "__main__":
    port = 8000
    with cloudflared(port=port) as cloudflared_address:
        print(f" * Running on {cloudflared_address}")
        uvicorn.run(app, port=port)

This will start cloudflared and then start the FastAPI server. The app will be publicly available at the cloudflared address e.g. something like https://rp-son-configured-army.trycloudflare.com.

The first time you run this it will take a few seconds to download and start cloudflared. Subsequent runs will be much faster.

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

with_cloudflared-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

with_cloudflared-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file with_cloudflared-0.1.0.tar.gz.

File metadata

  • Download URL: with_cloudflared-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.2

File hashes

Hashes for with_cloudflared-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6a934d1a95fd5be5c4506def73f8c569c817902feb4e2ac13e9446198097a0e9
MD5 e3aae4f551285d7941169fbf6a0e3495
BLAKE2b-256 9d791f0f53b861f46c1031212f1a899b32024342d466598e1afd2d0ef9673849

See more details on using hashes here.

File details

Details for the file with_cloudflared-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for with_cloudflared-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d90c0d1e7cf6e2116becf50c6eddab07ab148b40ca702ba8506e7fe09222b149
MD5 55ce4ea42b6bb336cc17a6b478316e99
BLAKE2b-256 8f81554979cf3b18b87dcbcfdbca89f184997324528b5dfb4d2e7a2802051b8a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page