Skip to main content

Gradio-FastAPI: Publicly Share and Demo Your FastAPI Apps Through Gradio Tunneling

This repository provides a simple and efficient way to tunnel any FastAPI application through a public Gradio URL. By leveraging this tool, developers can quickly demo and share their FastAPI applications with others without the need for complex server configurations or deployment processes. Ideal for quick prototyping, testing, and collaborative development, this solution ensures your FastAPI app is accessible from anywhere with minimal setup.

Features

  • Seamless Integration: Easily connect your FastAPI app to a public Gradio URL.
  • Quick Setup: Get your FastAPI app running publicly in just a few steps.
  • Convenient Sharing: Share your app with collaborators via a simple URL.
  • Efficient Prototyping: Perfect for quick demos, testing, and feedback collection.

Installation

pip install fastapi-gradio

Usage

  1. Import the tunnel lifespan function initializer in your FastAPI app:

    from gradio_fastapi import gradio_lifespan_init
    
  2. Set the lifespan of the App:

    1. If you do not already have a lifespan function defined:
      app = FastAPI(lifespan=gradio_lifespan_init())
      
    2. If you do
      app = FastAPI(lifespan=gradio_lifespan_init(my_lifespan))
      
  3. Run your app and get the public Gradio URL for sharing logged using uvicorn:

    fastapi dev main.py
    

Example

Check out example.py for a sample FastAPI application using this tunnel.

Contributions

Feel free to open issues or submit pull requests. Contributions are welcome!

License

This project is licensed under the MIT License.

Metadata

Release files for gradio-fastapi 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gradio-fastapi 0.1.0
File Size Uploaded
gradio_fastapi-0.1.0.tar.gz 5.4 kB Details

Release files / gradio_fastapi-0.1.0.tar.gz

Download URL gradio_fastapi-0.1.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
31774426d4753658ba6d8c06608830e25d99a458185751de47519e58daa24df2
BLAKE2b-256 checksum
How to use checksums
8fed7c4ce6f5574e5924f7cb62943c1c2bd99de4f2197eba024148a7bfbeb836
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page