Easily Share and Demo Your FastAPI Apps using Gradio Public URL Tunneling
Project description
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
-
Import the tunnel lifespan function initializer in your FastAPI app:
from gradio_fastapi import gradio_lifespan_init
-
Set the lifespan of the App:
- If you do not already have a lifespan function defined:
app = FastAPI(lifespan=gradio_lifespan_init())
- If you do
app = FastAPI(lifespan=gradio_lifespan_init(my_lifespan))
- If you do not already have a lifespan function defined:
-
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.