api / app.py
bobocup's picture
Update app.py
8909fcd verified
raw
history blame
739 Bytes
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)}
# 创建一个简单的 Gradio 界面
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")