| | import gradio as gr |
| | from fastapi import FastAPI |
| | import requests |
| |
|
| | app = FastAPI() |
| |
|
| | @app.get("/") |
| | def root(): |
| | try: |
| | response = requests.get("http://beibeioo.top") |
| | return response.content |
| | except Exception as e: |
| | return {"error": str(e)} |
| |
|
| | @app.get("/api/{path:path}") |
| | def api_proxy(path: str): |
| | try: |
| | response = requests.get(f"http://beibeioo.top/{path}") |
| | return response.content |
| | except Exception as e: |
| | return {"error": str(e)} |
| |
|
| | |
| | interface = gr.Interface( |
| | fn=lambda x: x, |
| | inputs=gr.Textbox(visible=False), |
| | outputs=gr.Textbox(visible=False), |
| | title="API Proxy" |
| | ) |
| |
|
| | |
| | app = gr.mount_gradio_app(app, interface, path="/ui") |